diff --git a/changelog b/changelog
index 832ed65..b5f1e9a 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,8 @@
+20110802 tpd src/axiom-website/patches.html 20110802.01.tpd.patch
+20110802 tpd src/interp/i-funsel.lisp pick up functions from database.lisp
+20110802 tpd src/interp/i-analy.lisp pick up functions from database.lisp
+20110802 tpd src/interp/Makefile remove database.lisp
+20110802 tpd src/interp/database.lisp removed
 20110801 tpd src/axiom-website/patches.html 20110801.01.tpd.patch
 20110801 tpd src/interp/database.lisp treeshake compiler
 20110801 tpd books/bookvol5 treeshake interpreter
diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html
index 64903ae..249ea2b 100644
--- a/src/axiom-website/patches.html
+++ b/src/axiom-website/patches.html
@@ -3570,5 +3570,7 @@ books/bookvol9 treeshake compiler<br/>
 books/bookvol9 treeshake compiler<br/>
 <a href="patches/20110801.01.tpd.patch">20110801.01.tpd.patch</a>
 books/bookvol9 treeshake compiler<br/>
+<a href="patches/20110802.01.tpd.patch">20110802.01.tpd.patch</a>
+src/interp/database.lisp removed
  </body>
 </html>
diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet
index 6666cc6..ef24b0f 100644
--- a/src/interp/Makefile.pamphlet
+++ b/src/interp/Makefile.pamphlet
@@ -144,7 +144,6 @@ OBJS= ${OUT}/vmlisp.${O}      \
       ${OUT}/cfuns.${O} \
       ${OUT}/clam.${O}        ${OUT}/clammed.${O} \
       ${OUT}/compress.${O} \
-      ${OUT}/database.${O} \
       ${OUT}/format.${O} \
       ${OUT}/g-boot.${O}      ${OUT}/g-cndata.${O} \
       ${OUT}/g-error.${O}     ${OUT}/g-opt.${O} \
@@ -1696,31 +1695,6 @@ ${MID}/compress.lisp: ${IN}/compress.lisp.pamphlet
 
 @
 
-\subsection{database.lisp}
-<<database.o (OUT from MID)>>=
-${OUT}/database.${O}: ${MID}/database.lisp
-	@ echo 136 making ${OUT}/database.${O} from ${MID}/database.lisp
-	@ ( cd ${MID} ; \
-	  if [ -z "${NOISE}" ] ; then \
-	   echo '(progn  (compile-file "${MID}/database.lisp"' \
-             ':output-file "${OUT}/database.${O}") (${BYE}))' | ${DEPSYS} ; \
-	  else \
-	   echo '(progn  (compile-file "${MID}/database.lisp"' \
-             ':output-file "${OUT}/database.${O}") (${BYE}))' | ${DEPSYS} \
-             >${TMP}/trace ; \
-	  fi )
-
-@
-<<database.lisp (MID from IN)>>=
-${MID}/database.lisp: ${IN}/database.lisp.pamphlet
-	@ echo 137 making ${MID}/database.lisp from \
-           ${IN}/database.lisp.pamphlet
-	@ (cd ${MID} ; \
-          echo '(tangle "${IN}/database.lisp.pamphlet" "*" "database.lisp")' \
-        | ${OBJ}/${SYS}/bin/lisp )
-
-@
-
 \subsection{define.lisp}
 <<define.o (OUT from MID)>>=
 ${OUT}/define.${O}: ${MID}/define.lisp
@@ -3348,9 +3322,6 @@ clean:
 <<c-util.o (OUT from MID)>>
 <<c-util.lisp (MID from IN)>>
 
-<<database.o (OUT from MID)>>
-<<database.lisp (MID from IN)>>
-
 <<debugsys.lisp (MID from IN)>>
 
 <<define.o (OUT from MID)>>
diff --git a/src/interp/database.lisp.pamphlet b/src/interp/database.lisp.pamphlet
deleted file mode 100644
index 3a98992..0000000
--- a/src/interp/database.lisp.pamphlet
+++ /dev/null
@@ -1,282 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/interp database.boot}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\begin{chunk}{*}
-(IN-PACKAGE "BOOT" )
-
-(SETANDFILEQ |$getUnexposedOperations| 'T)
-
-(defun |getDomainFromMm| (mm)
- (let (c cond condList val)
-  (setq cond (cadr mm))
-  (when (and (pairp cond) (eq (qcar cond) '|partial|))
-    (setq cond (qcdr cond)))
-  (setq condList
-   (cond
-    ((and (pairp cond) (eq (qcar cond) 'and))
-      (qcdr cond))
-    ((and (pairp cond) (eq (qcar cond) 'or)
-          (pairp (qcdr cond)) (pairp (qcar (qcdr cond)))
-          (eq (qcar (qcar (qcdr cond))) 'and))
-      (qcdr (qcar (qcdr cond))))
-    (t (list cond))))
-  (setq val
-   (dolist (condition condList)
-    (when
-      (and (pairp condition) 
-           (or (eq (qcar condition) '|isDomain|)
-               (eq (qcar condition) '|ofCategory|))
-           (pairp (qcdr condition))
-           (eq (qcar (qcdr condition)) '*1)
-           (pairp (qcdr (qcdr condition)))
-           (eq (qcdr (qcdr (qcdr condition))) nil))
-      (return (|opOf| (caddr condition))))))
-   (cond
-    ((null val)
-     (|keyedSystemError| 'S2GE0016
-      (list "getDomainFromMm" "Can't find domain in modemap condition")))
-    (t val))))
-
-;getFirstArgTypeFromMm mm ==
-;  -- Returns the type of the first argument or nil
-;  [pats, cond] := mm
-;  [.,.,:args] := pats
-;  null args => nil
-;  arg1 := first args
-;  if cond is ['partial, :c] then cond := c
-;  condList :=
-;    cond is ['AND, :cl] => cl
-;    cond is ['OR, ['AND, :cl],:.] => cl  --all cl's should give same info
-;    [cond]
-;  type := nil
-;  for condition in condList while not type repeat
-;      if condition is ['isDomain, a1, dom] and a1=arg1 then type := dom
-;  type
-
-(DEFUN |getFirstArgTypeFromMm| (|mm|)
-  (PROG (|pats| |args| |arg1| |c| |cond| |cl| |condList| |ISTMP#1| |a1|
-                |ISTMP#2| |dom| |type|)
-    (RETURN
-      (SEQ (PROGN
-             (SPADLET |pats| (CAR |mm|))
-             (SPADLET |cond| (CADR |mm|))
-             (SPADLET |args| (CDDR |pats|))
-             (COND
-               ((NULL |args|) NIL)
-               ('T (SPADLET |arg1| (CAR |args|))
-                (COND
-                  ((AND (PAIRP |cond|) (EQ (QCAR |cond|) '|partial|)
-                        (PROGN (SPADLET |c| (QCDR |cond|)) 'T))
-                   (SPADLET |cond| |c|)))
-                (SPADLET |condList|
-                         (COND
-                           ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'AND)
-                                 (PROGN
-                                   (SPADLET |cl| (QCDR |cond|))
-                                   'T))
-                            |cl|)
-                           ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'OR)
-                                 (PROGN
-                                   (SPADLET |ISTMP#1| (QCDR |cond|))
-                                   (AND (PAIRP |ISTMP#1|)
-                                    (PROGN
-                                      (SPADLET |ISTMP#2|
-                                       (QCAR |ISTMP#1|))
-                                      (AND (PAIRP |ISTMP#2|)
-                                       (EQ (QCAR |ISTMP#2|) 'AND)
-                                       (PROGN
-                                         (SPADLET |cl|
-                                          (QCDR |ISTMP#2|))
-                                         'T))))))
-                            |cl|)
-                           ('T (CONS |cond| NIL))))
-                (SPADLET |type| NIL)
-                (DO ((G167357 |condList| (CDR G167357))
-                     (|condition| NIL))
-                    ((OR (ATOM G167357)
-                         (PROGN
-                           (SETQ |condition| (CAR G167357))
-                           NIL)
-                         (NULL (NULL |type|)))
-                     NIL)
-                  (SEQ (EXIT (COND
-                               ((AND (PAIRP |condition|)
-                                     (EQ (QCAR |condition|)
-                                      '|isDomain|)
-                                     (PROGN
-                                       (SPADLET |ISTMP#1|
-                                        (QCDR |condition|))
-                                       (AND (PAIRP |ISTMP#1|)
-                                        (PROGN
-                                          (SPADLET |a1|
-                                           (QCAR |ISTMP#1|))
-                                          (SPADLET |ISTMP#2|
-                                           (QCDR |ISTMP#1|))
-                                          (AND (PAIRP |ISTMP#2|)
-                                           (EQ (QCDR |ISTMP#2|) NIL)
-                                           (PROGN
-                                             (SPADLET |dom|
-                                              (QCAR |ISTMP#2|))
-                                             'T)))))
-                                     (BOOT-EQUAL |a1| |arg1|))
-                                (SPADLET |type| |dom|))
-                               ('T NIL)))))
-                |type|)))))))
-
-;isFreeFunctionFromMm mm ==
-;  -- This returns true is the modemap represents a free function, ie,
-;  -- one not coming from a domain or category.
-;  [., cond] := mm
-;  isFreeFunctionFromMmCond cond
-
-(DEFUN |isFreeFunctionFromMm| (|mm|)
-  (PROG (|cond|)
-    (RETURN
-      (PROGN
-        (SPADLET |cond| (CADR |mm|))
-        (|isFreeFunctionFromMmCond| |cond|)))))
-
-;isFreeFunctionFromMmCond cond ==
-;  -- This returns true is the modemap represents a free function, ie,
-;  -- one not coming from a domain or category.
-;  if cond is ['partial, :c] then cond := c
-;  condList :=
-;    cond is ['AND, :cl] => cl
-;    cond is ['OR, ['AND, :cl],:.] => cl  --all cl's should give same info
-;    [cond]
-;  iff := false
-;  for condition in condList while not iff repeat
-;      if condition is ['isFreeFunction, :.] then iff := true
-;  iff
-
-(DEFUN |isFreeFunctionFromMmCond| (|cond|)
-  (PROG (|c| |ISTMP#1| |ISTMP#2| |cl| |condList| |iff|)
-    (RETURN
-      (SEQ (PROGN
-             (COND
-               ((AND (PAIRP |cond|) (EQ (QCAR |cond|) '|partial|)
-                     (PROGN (SPADLET |c| (QCDR |cond|)) 'T))
-                (SPADLET |cond| |c|)))
-             (SPADLET |condList|
-                      (COND
-                        ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'AND)
-                              (PROGN (SPADLET |cl| (QCDR |cond|)) 'T))
-                         |cl|)
-                        ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'OR)
-                              (PROGN
-                                (SPADLET |ISTMP#1| (QCDR |cond|))
-                                (AND (PAIRP |ISTMP#1|)
-                                     (PROGN
-                                       (SPADLET |ISTMP#2|
-                                        (QCAR |ISTMP#1|))
-                                       (AND (PAIRP |ISTMP#2|)
-                                        (EQ (QCAR |ISTMP#2|) 'AND)
-                                        (PROGN
-                                          (SPADLET |cl|
-                                           (QCDR |ISTMP#2|))
-                                          'T))))))
-                         |cl|)
-                        ('T (CONS |cond| NIL))))
-             (SPADLET |iff| NIL)
-             (DO ((G167407 |condList| (CDR G167407))
-                  (|condition| NIL))
-                 ((OR (ATOM G167407)
-                      (PROGN (SETQ |condition| (CAR G167407)) NIL)
-                      (NULL (NULL |iff|)))
-                  NIL)
-               (SEQ (EXIT (COND
-                            ((AND (PAIRP |condition|)
-                                  (EQ (QCAR |condition|)
-                                      '|isFreeFunction|))
-                             (SPADLET |iff| 'T))
-                            ('T NIL)))))
-             |iff|)))))
-
-;getAllModemapsFromDatabase(op,nargs) ==
-;  $getUnexposedOperations: local := true
-;  startTimingProcess 'diskread
-;  ans := getSystemModemaps(op,nargs)
-;  stopTimingProcess 'diskread
-;  ans
-
-(DEFUN |getAllModemapsFromDatabase| (|op| |nargs|)
-  (PROG (|$getUnexposedOperations| |ans|)
-    (DECLARE (SPECIAL |$getUnexposedOperations|))
-    (RETURN
-      (PROGN
-        (SPADLET |$getUnexposedOperations| 'T)
-        (|startTimingProcess| '|diskread|)
-        (SPADLET |ans| (|getSystemModemaps| |op| |nargs|))
-        (|stopTimingProcess| '|diskread|)
-        |ans|))))
-
-;getModemapsFromDatabase(op,nargs) ==
-;  $getUnexposedOperations: local := false
-;  startTimingProcess 'diskread
-;  ans := getSystemModemaps(op,nargs)
-;  stopTimingProcess 'diskread
-;  ans
-
-(DEFUN |getModemapsFromDatabase| (|op| |nargs|)
-  (PROG (|$getUnexposedOperations| |ans|)
-    (DECLARE (SPECIAL |$getUnexposedOperations|))
-    (RETURN
-      (PROGN
-        (SPADLET |$getUnexposedOperations| NIL)
-        (|startTimingProcess| '|diskread|)
-        (SPADLET |ans| (|getSystemModemaps| |op| |nargs|))
-        (|stopTimingProcess| '|diskread|)
-        |ans|))))
-
-;getSystemModemaps(op,nargs) ==
-;  mml:= GETDATABASE(op,'OPERATION) =>
-;    mms := NIL
-;    for (x := [[.,:sig],.]) in mml repeat
-;      (NUMBERP nargs) and (nargs ^= #QCDR sig) => 'iterate
-;      $getUnexposedOperations or isFreeFunctionFromMm(x) or
-;        isExposedConstructor(getDomainFromMm(x)) => mms := [x,:mms]
-;      'iterate
-;    mms
-;  nil
-
-(DEFUN |getSystemModemaps| (|op| |nargs|)
-  (PROG (|mml| |sig| |mms|)
-    (DECLARE (SPECIAL |$getUnexposedOperations|))
-    (RETURN
-      (SEQ (COND
-             ((SPADLET |mml| (GETDATABASE |op| 'OPERATION))
-              (SPADLET |mms| NIL)
-              (DO ((G167451 |mml| (CDR G167451)) (|x| NIL))
-                  ((OR (ATOM G167451)
-                       (PROGN (SETQ |x| (CAR G167451)) NIL)
-                       (PROGN
-                         (PROGN (SPADLET |sig| (CDAR |x|)) |x|)
-                         NIL))
-                   NIL)
-                (SEQ (EXIT (COND
-                             ((AND (NUMBERP |nargs|)
-                                   (NEQUAL |nargs| (|#| (QCDR |sig|))))
-                              '|iterate|)
-                             ((OR |$getUnexposedOperations|
-                                  (|isFreeFunctionFromMm| |x|)
-                                  (|isExposedConstructor|
-                                      (|getDomainFromMm| |x|)))
-                              (SPADLET |mms| (CONS |x| |mms|)))
-                             ('T '|iterate|)))))
-              |mms|)
-             ('T NIL))))))
-
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/interp/i-analy.lisp.pamphlet b/src/interp/i-analy.lisp.pamphlet
index 3695637..58109d0 100644
--- a/src/interp/i-analy.lisp.pamphlet
+++ b/src/interp/i-analy.lisp.pamphlet
@@ -664,6 +664,64 @@
                                     ('T NIL)))))
                      (REVERSE |ok|)))))))))
 
+(SETANDFILEQ |$getUnexposedOperations| 'T)
+
+;getModemapsFromDatabase(op,nargs) ==
+;  $getUnexposedOperations: local := false
+;  startTimingProcess 'diskread
+;  ans := getSystemModemaps(op,nargs)
+;  stopTimingProcess 'diskread
+;  ans
+
+(DEFUN |getModemapsFromDatabase| (|op| |nargs|)
+  (PROG (|$getUnexposedOperations| |ans|)
+    (DECLARE (SPECIAL |$getUnexposedOperations|))
+    (RETURN
+      (PROGN
+        (SPADLET |$getUnexposedOperations| NIL)
+        (|startTimingProcess| '|diskread|)
+        (SPADLET |ans| (|getSystemModemaps| |op| |nargs|))
+        (|stopTimingProcess| '|diskread|)
+        |ans|))))
+
+;getSystemModemaps(op,nargs) ==
+;  mml:= GETDATABASE(op,'OPERATION) =>
+;    mms := NIL
+;    for (x := [[.,:sig],.]) in mml repeat
+;      (NUMBERP nargs) and (nargs ^= #QCDR sig) => 'iterate
+;      $getUnexposedOperations or isFreeFunctionFromMm(x) or
+;        isExposedConstructor(getDomainFromMm(x)) => mms := [x,:mms]
+;      'iterate
+;    mms
+;  nil
+
+(DEFUN |getSystemModemaps| (|op| |nargs|)
+  (PROG (|mml| |sig| |mms|)
+    (DECLARE (SPECIAL |$getUnexposedOperations|))
+    (RETURN
+      (SEQ (COND
+             ((SPADLET |mml| (GETDATABASE |op| 'OPERATION))
+              (SPADLET |mms| NIL)
+              (DO ((G167451 |mml| (CDR G167451)) (|x| NIL))
+                  ((OR (ATOM G167451)
+                       (PROGN (SETQ |x| (CAR G167451)) NIL)
+                       (PROGN
+                         (PROGN (SPADLET |sig| (CDAR |x|)) |x|)
+                         NIL))
+                   NIL)
+                (SEQ (EXIT (COND
+                             ((AND (NUMBERP |nargs|)
+                                   (NEQUAL |nargs| (|#| (QCDR |sig|))))
+                              '|iterate|)
+                             ((OR |$getUnexposedOperations|
+                                  (|isFreeFunctionFromMm| |x|)
+                                  (|isExposedConstructor|
+                                      (|getDomainFromMm| |x|)))
+                              (SPADLET |mms| (CONS |x| |mms|)))
+                             ('T '|iterate|)))))
+              |mms|)
+             ('T NIL))))))
+
 ;--% Bottom Up Processing
 ;-- Also see I-SPEC BOOT for special handlers and I-MAP BOOT for
 ;-- user function processing.
@@ -1490,6 +1548,92 @@
                              (CONS (|mkAtreeNode| '|Tuple|) |args|))
                     (|bottomUp| (CONS |op| (CONS |newArg| NIL)))))))))))))
 
+;getFirstArgTypeFromMm mm ==
+;  -- Returns the type of the first argument or nil
+;  [pats, cond] := mm
+;  [.,.,:args] := pats
+;  null args => nil
+;  arg1 := first args
+;  if cond is ['partial, :c] then cond := c
+;  condList :=
+;    cond is ['AND, :cl] => cl
+;    cond is ['OR, ['AND, :cl],:.] => cl  --all cl's should give same info
+;    [cond]
+;  type := nil
+;  for condition in condList while not type repeat
+;      if condition is ['isDomain, a1, dom] and a1=arg1 then type := dom
+;  type
+
+(DEFUN |getFirstArgTypeFromMm| (|mm|)
+  (PROG (|pats| |args| |arg1| |c| |cond| |cl| |condList| |ISTMP#1| |a1|
+                |ISTMP#2| |dom| |type|)
+    (RETURN
+      (SEQ (PROGN
+             (SPADLET |pats| (CAR |mm|))
+             (SPADLET |cond| (CADR |mm|))
+             (SPADLET |args| (CDDR |pats|))
+             (COND
+               ((NULL |args|) NIL)
+               ('T (SPADLET |arg1| (CAR |args|))
+                (COND
+                  ((AND (PAIRP |cond|) (EQ (QCAR |cond|) '|partial|)
+                        (PROGN (SPADLET |c| (QCDR |cond|)) 'T))
+                   (SPADLET |cond| |c|)))
+                (SPADLET |condList|
+                         (COND
+                           ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'AND)
+                                 (PROGN
+                                   (SPADLET |cl| (QCDR |cond|))
+                                   'T))
+                            |cl|)
+                           ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'OR)
+                                 (PROGN
+                                   (SPADLET |ISTMP#1| (QCDR |cond|))
+                                   (AND (PAIRP |ISTMP#1|)
+                                    (PROGN
+                                      (SPADLET |ISTMP#2|
+                                       (QCAR |ISTMP#1|))
+                                      (AND (PAIRP |ISTMP#2|)
+                                       (EQ (QCAR |ISTMP#2|) 'AND)
+                                       (PROGN
+                                         (SPADLET |cl|
+                                          (QCDR |ISTMP#2|))
+                                         'T))))))
+                            |cl|)
+                           ('T (CONS |cond| NIL))))
+                (SPADLET |type| NIL)
+                (DO ((G167357 |condList| (CDR G167357))
+                     (|condition| NIL))
+                    ((OR (ATOM G167357)
+                         (PROGN
+                           (SETQ |condition| (CAR G167357))
+                           NIL)
+                         (NULL (NULL |type|)))
+                     NIL)
+                  (SEQ (EXIT (COND
+                               ((AND (PAIRP |condition|)
+                                     (EQ (QCAR |condition|)
+                                      '|isDomain|)
+                                     (PROGN
+                                       (SPADLET |ISTMP#1|
+                                        (QCDR |condition|))
+                                       (AND (PAIRP |ISTMP#1|)
+                                        (PROGN
+                                          (SPADLET |a1|
+                                           (QCAR |ISTMP#1|))
+                                          (SPADLET |ISTMP#2|
+                                           (QCDR |ISTMP#1|))
+                                          (AND (PAIRP |ISTMP#2|)
+                                           (EQ (QCDR |ISTMP#2|) NIL)
+                                           (PROGN
+                                             (SPADLET |dom|
+                                              (QCAR |ISTMP#2|))
+                                             'T)))))
+                                     (BOOT-EQUAL |a1| |arg1|))
+                                (SPADLET |type| |dom|))
+                               ('T NIL)))))
+                |type|)))))))
+
 ;removeUnionsAtStart(argl,modeSets) ==
 ;  null $genValue => modeSets
 ;  for arg in argl for ms in modeSets repeat
@@ -1892,6 +2036,24 @@
                                       NIL)))))))))
          NIL)))))
 
+;getAllModemapsFromDatabase(op,nargs) ==
+;  $getUnexposedOperations: local := true
+;  startTimingProcess 'diskread
+;  ans := getSystemModemaps(op,nargs)
+;  stopTimingProcess 'diskread
+;  ans
+
+(DEFUN |getAllModemapsFromDatabase| (|op| |nargs|)
+  (PROG (|$getUnexposedOperations| |ans|)
+    (DECLARE (SPECIAL |$getUnexposedOperations|))
+    (RETURN
+      (PROGN
+        (SPADLET |$getUnexposedOperations| 'T)
+        (|startTimingProcess| '|diskread|)
+        (SPADLET |ans| (|getSystemModemaps| |op| |nargs|))
+        (|stopTimingProcess| '|diskread|)
+        |ans|))))
+
 ;bottomUpType(t, type) ==
 ;  mode :=
 ;    if isPartialMode type then '(Mode)
diff --git a/src/interp/i-funsel.lisp.pamphlet b/src/interp/i-funsel.lisp.pamphlet
index 866b731..6a7f8e3 100644
--- a/src/interp/i-funsel.lisp.pamphlet
+++ b/src/interp/i-funsel.lisp.pamphlet
@@ -3601,6 +3601,106 @@ the types A and B themselves are not sorted by preference.
                                    (setq |bad| (CONS |mm| |bad|)))))))))))))
              (CONS |good| (CONS |bad| NIL)))))))
 
+;isFreeFunctionFromMm mm ==
+;  -- This returns true is the modemap represents a free function, ie,
+;  -- one not coming from a domain or category.
+;  [., cond] := mm
+;  isFreeFunctionFromMmCond cond
+
+(DEFUN |isFreeFunctionFromMm| (|mm|)
+  (PROG (|cond|)
+    (RETURN
+      (PROGN
+        (SPADLET |cond| (CADR |mm|))
+        (|isFreeFunctionFromMmCond| |cond|)))))
+
+;isFreeFunctionFromMmCond cond ==
+;  -- This returns true is the modemap represents a free function, ie,
+;  -- one not coming from a domain or category.
+;  if cond is ['partial, :c] then cond := c
+;  condList :=
+;    cond is ['AND, :cl] => cl
+;    cond is ['OR, ['AND, :cl],:.] => cl  --all cl's should give same info
+;    [cond]
+;  iff := false
+;  for condition in condList while not iff repeat
+;      if condition is ['isFreeFunction, :.] then iff := true
+;  iff
+
+(DEFUN |isFreeFunctionFromMmCond| (|cond|)
+  (PROG (|c| |ISTMP#1| |ISTMP#2| |cl| |condList| |iff|)
+    (RETURN
+      (SEQ (PROGN
+             (COND
+               ((AND (PAIRP |cond|) (EQ (QCAR |cond|) '|partial|)
+                     (PROGN (SPADLET |c| (QCDR |cond|)) 'T))
+                (SPADLET |cond| |c|)))
+             (SPADLET |condList|
+                      (COND
+                        ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'AND)
+                              (PROGN (SPADLET |cl| (QCDR |cond|)) 'T))
+                         |cl|)
+                        ((AND (PAIRP |cond|) (EQ (QCAR |cond|) 'OR)
+                              (PROGN
+                                (SPADLET |ISTMP#1| (QCDR |cond|))
+                                (AND (PAIRP |ISTMP#1|)
+                                     (PROGN
+                                       (SPADLET |ISTMP#2|
+                                        (QCAR |ISTMP#1|))
+                                       (AND (PAIRP |ISTMP#2|)
+                                        (EQ (QCAR |ISTMP#2|) 'AND)
+                                        (PROGN
+                                          (SPADLET |cl|
+                                           (QCDR |ISTMP#2|))
+                                          'T))))))
+                         |cl|)
+                        ('T (CONS |cond| NIL))))
+             (SPADLET |iff| NIL)
+             (DO ((G167407 |condList| (CDR G167407))
+                  (|condition| NIL))
+                 ((OR (ATOM G167407)
+                      (PROGN (SETQ |condition| (CAR G167407)) NIL)
+                      (NULL (NULL |iff|)))
+                  NIL)
+               (SEQ (EXIT (COND
+                            ((AND (PAIRP |condition|)
+                                  (EQ (QCAR |condition|)
+                                      '|isFreeFunction|))
+                             (SPADLET |iff| 'T))
+                            ('T NIL)))))
+             |iff|)))))
+
+(defun |getDomainFromMm| (mm)
+ (let (c cond condList val)
+  (setq cond (cadr mm))
+  (when (and (pairp cond) (eq (qcar cond) '|partial|))
+    (setq cond (qcdr cond)))
+  (setq condList
+   (cond
+    ((and (pairp cond) (eq (qcar cond) 'and))
+      (qcdr cond))
+    ((and (pairp cond) (eq (qcar cond) 'or)
+          (pairp (qcdr cond)) (pairp (qcar (qcdr cond)))
+          (eq (qcar (qcar (qcdr cond))) 'and))
+      (qcdr (qcar (qcdr cond))))
+    (t (list cond))))
+  (setq val
+   (dolist (condition condList)
+    (when
+      (and (pairp condition) 
+           (or (eq (qcar condition) '|isDomain|)
+               (eq (qcar condition) '|ofCategory|))
+           (pairp (qcdr condition))
+           (eq (qcar (qcdr condition)) '*1)
+           (pairp (qcdr (qcdr condition)))
+           (eq (qcdr (qcdr (qcdr condition))) nil))
+      (return (|opOf| (caddr condition))))))
+   (cond
+    ((null val)
+     (|keyedSystemError| 'S2GE0016
+      (list "getDomainFromMm" "Can't find domain in modemap condition")))
+    (t val))))
+
 ;isTowerWithSubdomain(towerType,elem) ==
 ;  not PAIRP towerType => NIL
 ;  dt := deconstructT towerType
