diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-05 v0.8.1.0
+	* Reinstate processing of CPP directives as comments #36
+	* Fix problem in renaming in a client module when the old name is
+	not in scope in the client module. #35
+	* No longer mark a client module as refactored if no renaming
+	takes place in it.
 2015-10-04 v0.8.0.0
 	* Major rework, replacing haskell-token-utils with ghc-exactprint
 	* Now supports GHC 7.10.2 and up. ONLY.
diff --git a/HaRe.cabal b/HaRe.cabal
--- a/HaRe.cabal
+++ b/HaRe.cabal
@@ -1,5 +1,5 @@
 Name:                           HaRe
-Version:                        0.8.0.0
+Version:                        0.8.1.0
 Author:                         Chris Brown, Huiqing Li, Simon Thompson, Alan Zimmerman
 Maintainer:                     Alan Zimmerman
 Stability:                      Alpha
@@ -112,7 +112,6 @@
                                 , containers
                                 , directory
 
-                                -- , dual-tree
                                 , semigroups
                                 , monoid-extras
 
@@ -137,10 +136,7 @@
                                 , ghc-exactprint >= 0.4.1
                                 , monad-control
                                 , Cabal >= 1.22
-                                -- , uniplate
 
-        -- GHC-Options:             -Wall -O0
-
         Hs-Source-Dirs:         src
         -- Other-Modules:          Paths_HaRe
         Exposed-modules:
@@ -205,7 +201,6 @@
                                 , containers
                                 , directory
 
-                                -- , dual-tree
                                 , semigroups
                                 , monoid-extras
 
@@ -252,7 +247,7 @@
   main-is:
       Spec.hs
   Hs-Source-Dirs:
-    -- src
+    src
     test
   other-modules:
       CaseSpec
@@ -268,6 +263,25 @@
     , TestUtils
     , TypeUtilsSpec
     , UtilsSpec
+
+    , Language.Haskell.Refact.API
+    , Language.Haskell.Refact.HaRe
+    , Language.Haskell.Refact.Refactoring.Case
+    , Language.Haskell.Refact.Refactoring.RoundTrip
+    , Language.Haskell.Refact.Utils.Binds
+    , Language.Haskell.Refact.Utils.ExactPrint
+    , Language.Haskell.Refact.Utils.GhcModuleGraph
+    , Language.Haskell.Refact.Utils.GhcUtils
+    , Language.Haskell.Refact.Utils.GhcVersionSpecific
+    , Language.Haskell.Refact.Utils.LocUtils
+    , Language.Haskell.Refact.Utils.Monad
+    , Language.Haskell.Refact.Utils.MonadFunctions
+    , Language.Haskell.Refact.Utils.TypeSyn
+    , Language.Haskell.Refact.Utils.TypeUtils
+    , Language.Haskell.Refact.Utils.Types
+    , Language.Haskell.Refact.Utils.Utils
+    , Language.Haskell.Refact.Utils.Variables
+    , Paths_HaRe
   build-depends:
       -- GHC 7.10.2 ships with base 4.8.1.0
       base        >= 4.8.1.0  && < 4.9
@@ -276,7 +290,7 @@
     , QuickCheck  >= 2.5
     , containers
 
-    -- , dual-tree
+    , cabal-helper
     , semigroups
     , monoid-extras
 
@@ -284,7 +298,6 @@
     , directory
     , filepath
     , ghc
-    -- , ghc-paths   == 0.1.*
     , ghc-paths
     , ghc-prim
     , ghc-syb-utils
@@ -306,10 +319,8 @@
     , ghc-exactprint >= 0.4.1
     , monad-control
     , Cabal >= 1.22
-    -- , uniplate
     -- , Paths_HaRe
-    -- , haskell-token-utils >= 0.0.0.6
-    , HaRe >= 0.8
+    -- , HaRe >= 0.8
   Extensions:      CPP
   if impl (ghc < 7.10.2)
     buildable: False
diff --git a/src/Language/Haskell/Refact/Refactoring/Renaming.hs b/src/Language/Haskell/Refact/Refactoring/Renaming.hs
--- a/src/Language/Haskell/Refact/Refactoring/Renaming.hs
+++ b/src/Language/Haskell/Refact/Refactoring/Renaming.hs
@@ -188,6 +188,7 @@
                                                r' <- getRefactRenamed
                                                return r'
 
+-- ---------------------------------------------------------------------
 
 renameInClientMod :: GHC.Name -> String -> GHC.Name -> TargetModule
                   -> RefactGhc [ApplyRefacResult]
@@ -215,34 +216,42 @@
       -- logm $ "renameInClientMod:(newNamesUnqual,oldPN)=" ++ showGhcQual (newNamesUnqual,oldPN)
       -- logm $ "renameInClientMod:(newNames,oldPN)=" ++ showGhcQual (newNames,oldPN)
       -- logm $ "renameInClientMod:(uniques:newNames,oldPN)=" ++ showGhcQual (map GHC.nameUnique newNames,GHC.nameUnique oldPN)
-      let oldNameGhc = case newNames of
-            [n] -> n
-            ns  -> error $ "HaRe:renameInClientMod:could not find name to replace,got:" ++ showGhcQual ns
-
-      -- There are two different tests we need to do here
-      -- 1. Does the new name clash with some existing name in the
-      --    client mod, in which case it must be qualified
-      -- 2. Is the new name module imported qualified, and so needs to
-      --    be qualified in the replacement, according to the import
-      isInScopeUnqual    <- isInScopeAndUnqualifiedGhc (nameToString oldPN) Nothing
-      isInScopeUnqualNew <- isInScopeAndUnqualifiedGhc newName              Nothing
-      logm $ "renameInClientMod: (isInScopeAndUnqual,isInScopeUnqualNew)=" ++ (show (isInScopeUnqual,isInScopeUnqualNew)) -- ++AZ++
-      if isInScopeUnqualNew -- ++AZ++: should this be negated?
-       then
-        do
-           -- (refactoredMod,_) <- applyRefac (refactRenameSimple oldPN newName newNameGhc True) RSAlreadyLoaded
-           (refactoredMod,_) <- applyRefac (refactRenameSimple oldNameGhc newName newNameGhc True) RSAlreadyLoaded
-           return [refactoredMod]
-       else
-        do
-           if causeNameClashInExports oldPN newNameGhc modName renamed
-             then error $"The new name will cause conflicting exports in module "++ show newName ++ ", please select another name!"
+      case newNames of
+        []        -> return []
+        [oldName] ->
+          if findPN oldName renamed
+             then doRenameInClientMod oldName modName renamed
              else do
-               -- (refactoredMod,_) <- applyRefac (refactRenameComplex oldPN newName newNameGhc) RSAlreadyLoaded
-               (refactoredMod,_) <- applyRefac (refactRenameComplex oldNameGhc newName newNameGhc) RSAlreadyLoaded
-               -- TODO: implement rest of this
-               return [refactoredMod]
+               logm $ "renameInClientMod:name not present in module, returning"
+               return []
+        ns  -> error $ "HaRe:renameInClientMod:could not find name to replace,got:" ++ showGhcQual ns
+
   where
+     doRenameInClientMod oldNameGhc modName renamed = do
+        -- There are two different tests we need to do here
+        -- 1. Does the new name clash with some existing name in the
+        --    client mod, in which case it must be qualified
+        -- 2. Is the new name module imported qualified, and so needs to
+        --    be qualified in the replacement, according to the import
+        isInScopeUnqual    <- isInScopeAndUnqualifiedGhc (nameToString oldPN) Nothing
+        isInScopeUnqualNew <- isInScopeAndUnqualifiedGhc newName              Nothing
+        logm $ "renameInClientMod: (isInScopeAndUnqual,isInScopeUnqualNew)=" ++ (show (isInScopeUnqual,isInScopeUnqualNew)) -- ++AZ++
+        if isInScopeUnqualNew -- ++AZ++: should this be negated?
+         then
+          do
+             -- (refactoredMod,_) <- applyRefac (refactRenameSimple oldPN newName newNameGhc True) RSAlreadyLoaded
+             (refactoredMod,_) <- applyRefac (refactRenameSimple oldNameGhc newName newNameGhc True) RSAlreadyLoaded
+             return [refactoredMod]
+         else
+          do
+             if causeNameClashInExports oldPN newNameGhc modName renamed
+               then error $"The new name will cause conflicting exports in module "++ show newName ++ ", please select another name!"
+               else do
+                 -- (refactoredMod,_) <- applyRefac (refactRenameComplex oldPN newName newNameGhc) RSAlreadyLoaded
+                 (refactoredMod,_) <- applyRefac (refactRenameComplex oldNameGhc newName newNameGhc) RSAlreadyLoaded
+                 -- TODO: implement rest of this
+                 return [refactoredMod]
+
      refactRenameSimple :: GHC.Name -> String -> GHC.Name -> Bool -> RefactGhc ()
      refactRenameSimple old newStr new useQual = do
        logm $ "refactRenameSimple:(old,newStr,new,useQual)=" ++ showGhc (old,newStr,new,useQual)
diff --git a/src/Language/Haskell/Refact/Utils/MonadFunctions.hs b/src/Language/Haskell/Refact/Utils/MonadFunctions.hs
--- a/src/Language/Haskell/Refact/Utils/MonadFunctions.hs
+++ b/src/Language/Haskell/Refact/Utils/MonadFunctions.hs
@@ -118,6 +118,7 @@
 -- |For testing
 setRefactStreamModified :: RefacResult -> RefactGhc ()
 setRefactStreamModified rr = do
+  logm $ "setRefactStreamModified:rr=" ++ show rr
   st <- get
   let (Just tm) = rsModule st
   put $ st { rsModule = Just (tm { rsStreamModified = rr })}
@@ -153,6 +154,7 @@
 
 putRefactParsed :: GHC.ParsedSource -> Anns -> RefactGhc ()
 putRefactParsed parsed newAnns = do
+  logm $ "putRefactParsed:setting rsStreamModified"
   st <- get
   mrm <- gets rsModule
   let rm = gfromJust "putRefactParsed" mrm
@@ -183,6 +185,7 @@
 -- RefactGhc state.
 modifyRefactAnns :: (Anns -> Anns) -> RefactGhc ()
 modifyRefactAnns f = do
+  logm $ "modifyRefactAnns:setting rsStreamModified"
   st <- get
   mrm <- gets rsModule
   let rm = gfromJust "modifyRefactAnns" mrm
@@ -202,10 +205,10 @@
 
 -- ----------------------------------------------------------------------
 
-putParsedModule :: GHC.TypecheckedModule -> RefactGhc ()
-putParsedModule tm = do
+putParsedModule :: [Comment] -> GHC.TypecheckedModule -> RefactGhc ()
+putParsedModule cppComments tm = do
   st <- get
-  put $ st { rsModule = initRefactModule tm }
+  put $ st { rsModule = initRefactModule cppComments tm }
 
 clearParsedModule :: RefactGhc ()
 clearParsedModule = do
@@ -395,12 +398,12 @@
 
 -- ---------------------------------------------------------------------
 
-initRefactModule
-  :: GHC.TypecheckedModule -> Maybe RefactModule
-initRefactModule tm
+initRefactModule :: [Comment] -> GHC.TypecheckedModule -> Maybe RefactModule
+initRefactModule cppComments tm
   = Just (RefMod { rsTypecheckedMod = tm
                  , rsNameMap = initRdrNameMap tm
-                 , rsTokenCache = initTokenCacheLayout (relativiseApiAnns
+                 , rsTokenCache = initTokenCacheLayout (relativiseApiAnnsWithComments
+                                     cppComments
                                     (GHC.pm_parsed_source $ GHC.tm_parsed_module tm)
                                     (GHC.pm_annotations $ GHC.tm_parsed_module tm))
                  , rsStreamModified = RefacUnmodifed
diff --git a/src/Language/Haskell/Refact/Utils/Utils.hs b/src/Language/Haskell/Refact/Utils/Utils.hs
--- a/src/Language/Haskell/Refact/Utils/Utils.hs
+++ b/src/Language/Haskell/Refact/Utils/Utils.hs
@@ -21,7 +21,6 @@
        , refactDone
 
        , Update(..)
-       -- , fileNameToModName
        , fileNameFromModSummary
        , getModuleName
        , clientModsAndFiles
@@ -34,6 +33,7 @@
 import Data.List
 
 import Language.Haskell.GHC.ExactPrint
+import Language.Haskell.GHC.ExactPrint.Preprocess
 import Language.Haskell.GHC.ExactPrint.Utils
 
 import qualified Language.Haskell.GhcMod          as GM
@@ -107,6 +107,19 @@
   p <- GHC.parseModule modSum
   t <- GHC.typecheckModule p
 
+  -- dflags <- GHC.getDynFlags
+  -- cppComments <- if (GHC.xopt GHC.Opt_Cpp dflags)
+  cppComments <- if True
+                  then do
+                       -- ++AZ++:TODO: enable the CPP option check some time
+                       logm $ "loadFromModSummary:CPP flag set"
+                       case GHC.ml_hs_file $ GHC.ms_location modSum of
+                         Just fileName -> getCppTokensAsComments defaultCppOptions fileName
+                         Nothing       -> return []
+                  else do
+                       logm $ "loadFromModSummary:no CPP"
+                       return []
+
   -- required for inscope queries. Is there a better way to do those?
   setGhcContext modSum
 
@@ -118,7 +131,7 @@
   oldTargetModule <- gets rsCurrentTarget
   let
     putModule = do
-      putParsedModule t
+      putParsedModule cppComments t
       settings <- get
       put $ settings { rsCurrentTarget = Just newTargetModule }
 
@@ -237,7 +250,7 @@
 
     res <- refac  -- Run the refactoring, updating the state as required
 
-    mod'   <- getRefactParsed
+    mod' <- getRefactParsed
     anns <- fetchAnnsFinal
     m    <- getRefactStreamModified
 
diff --git a/test/GhcUtilsSpec.hs b/test/GhcUtilsSpec.hs
--- a/test/GhcUtilsSpec.hs
+++ b/test/GhcUtilsSpec.hs
@@ -18,6 +18,7 @@
 import Language.Haskell.Refact.Utils.Monad
 import Language.Haskell.Refact.Utils.MonadFunctions
 import Language.Haskell.Refact.Utils.TypeUtils
+import Language.Haskell.Refact.Utils.Utils
 import Language.Haskell.Refact.Utils.Variables
 
 -- import TestUtils
@@ -48,9 +49,9 @@
     -- ---------------------------------
 
     it "Finds a GHC.Name at top level only" $ do
-      t <- ct $ parsedFileGhc "./DupDef/Dd1.hs"
       let
         comp = do
+         parseSourceFileGhc "./DupDef/Dd1.hs"
          renamed <- getRefactRenamed
 
          let mn = locToName (4,1) renamed
@@ -78,7 +79,7 @@
              g2 = onelayerStaged SYB.Renamer ["-1"] (["-10"] `SYB.mkQ` worker2) duplicatedDecls
 
          return (res,res2,resx,resx2,duplicatedDecls,g,g2,ln,lx)
-      ((r,r2,rx,rx2,d,gg,gg2,_l,_x),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,r2,rx,rx2,d,gg,gg2,_l,_x),_s) <- ct $ runRefactGhc comp initialState testOptions
       -- (SYB.showData SYB.Renamer 0 d) `shouldBe` ""
 
       (showGhcQual d) `shouldBe` "[DupDef.Dd1.toplevel x = DupDef.Dd1.c GHC.Num.* x]"
diff --git a/test/LocUtilsSpec.hs b/test/LocUtilsSpec.hs
--- a/test/LocUtilsSpec.hs
+++ b/test/LocUtilsSpec.hs
@@ -10,6 +10,7 @@
 import Language.Haskell.Refact.Utils.LocUtils
 import Language.Haskell.Refact.Utils.Monad
 import Language.Haskell.Refact.Utils.MonadFunctions
+import Language.Haskell.Refact.Utils.Utils
 
 -- ---------------------------------------------------------------------
 
@@ -23,40 +24,32 @@
 
   describe "getSrcSpan" $ do
     it "Finds the top SrcSpan" $ do
-      t <- parsedFileDd1Ghc
       let
         comp = do
+         parseSourceFileGhc "./DupDef/Dd1.hs"
          parsed <- getRefactParsed
          decls <- liftT $ hsDecls parsed
          let ss = getSrcSpan decls
          return (decls,ss)
-      ((d,ss'),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((d,ss'),_s) <- ct $ runRefactGhc comp initialState testOptions
       (showGhcQual d) `shouldBe` "[toplevel :: Integer -> Integer, toplevel x = c * x,\n c, d :: Integer, c = 7, d = 9, tup :: (Int, Int), h :: Int,\n t :: Int,\n tup@(h, t)\n   = head $ zip [1 .. 10] [3 .. ff]\n   where\n       ff :: Int\n       ff = 15,\n data D = A | B String | C,\n ff y\n   = y + zz\n   where\n       zz = 1,\n l z = let ll = 34 in ll + z,\n dd q\n   = do { let ss = 5;\n          return (ss + q) }]"
       (showGhcQual ss') `shouldBe` "Just DupDef/Dd1.hs:3:1-30"
 
     -- -------------------------------
 
     it "Finds the SrcSpan for a top level decl" $ do
-      t <- parsedFileDemoteGhc
       let
         comp = do
+         parseSourceFileGhc "./MoveDef/Demote.hs"
          parsed <- getRefactParsed
          decls <- liftT $ hsDecls parsed
          let decl = head $ drop 2 decls
              ss = getSrcSpan decl
          return (decl,ss)
-      ((d,ss'),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((d,ss'),_s) <- ct $ runRefactGhc comp initialState testOptions
       (showGhcQual d) `shouldBe` "c = 7"
       (showGhcQual ss') `shouldBe` "Just MoveDef/Demote.hs:7:1-5"
 
 -- ---------------------------------------------------------------------
-
-parsedFileDd1Ghc :: IO ParseResult
-parsedFileDd1Ghc = ct $ parsedFileGhc "./DupDef/Dd1.hs"
-
--- -----------
-
-parsedFileDemoteGhc :: IO ParseResult
-parsedFileDemoteGhc = ct $ parsedFileGhc "./MoveDef/Demote.hs"
 
 -- EOF
diff --git a/test/RenamingSpec.hs b/test/RenamingSpec.hs
--- a/test/RenamingSpec.hs
+++ b/test/RenamingSpec.hs
@@ -55,7 +55,6 @@
      r' <- ct $ mapM makeRelativeToCurrentDirectory r
 
      r' `shouldBe` [ "Renaming/D2.hs"
-                   , "Renaming/A2.hs"
                    , "Renaming/B2.hs"
                    , "Renaming/C2.hs"
                    ]
@@ -72,10 +71,6 @@
                                 "./Renaming/B2.refactored.hs"
      diffB `shouldBe` []
 
-     -- diffA <- ct $ compareFiles "./Renaming/A2.hs.expected"
-     --                            "./Renaming/A2.refactored.hs"
-     -- diffA `shouldBe` []
-
     -- ---------------------------------
 
     it "renames in D3 B3 C3 A3 12 7" $ do
@@ -85,7 +80,6 @@
      r' <- ct $ mapM makeRelativeToCurrentDirectory r
 
      r' `shouldBe` [ "Renaming/D3.hs"
-                   , "Renaming/A3.hs"
                    , "Renaming/B3.hs"
                    , "Renaming/C3.hs"
                    ]
@@ -102,10 +96,6 @@
                                 "./Renaming/B3.refactored.hs"
      diffB `shouldBe` []
 
-     -- diffA <- ct $ compareFiles "./Renaming/A3.hs.expected"
-     --                            "./Renaming/A3.refactored.hs"
-     -- diffA `shouldBe` []
-
     -- ---------------------------------
 
     it "renames in D4 B4 C4 A4 13 4" $ do
@@ -596,7 +586,17 @@
                                "./Renaming/RenameInExportedType2.expected.hs"
      diff `shouldBe` []
 
+    -- -----------------------------------------------------------------
 
+{-
+    it "renames in slack-api" $ do
+     let cts = cdAndDo "/home/alanz/tmp/hackage/slack-api-0.6"
+     r <- cts $ rename defaultTestSettings testOptions "./src/Web/Slack/Utils.hs" "anyName" (14,1)
+     -- cdAndDo "/home/alanz/tmp/hackage/slack-api-0.6" $ rename logTestSettings testOptions "./src/Web/Slack/Utils.hs" "anyName" (14,1)
+
+     r' <- ct $ mapM makeRelativeToCurrentDirectory r
+     (show r') `shouldBe` "[\"Renaming/RenameInExportedType2.hs\"]"
+-}
 
 -- ---------------------------------------------------------------------
 -- Helper functions
diff --git a/test/TestUtils.hs b/test/TestUtils.hs
--- a/test/TestUtils.hs
+++ b/test/TestUtils.hs
@@ -42,7 +42,6 @@
 -- import qualified Outputable    as GHC
 import qualified Unique        as GHC
 
-import Control.Monad.State
 import Data.Algorithm.Diff
 import Data.Data
 import Exception
@@ -53,7 +52,6 @@
 import Language.Haskell.GHC.ExactPrint.Utils
 import qualified Language.Haskell.GhcMod as GM
 import qualified Language.Haskell.GhcMod.Types as GM
-import Language.Haskell.Refact.Utils.GhcBugWorkArounds
 import Language.Haskell.Refact.Utils.Monad
 import Language.Haskell.Refact.Utils.MonadFunctions
 import Language.Haskell.Refact.Utils.Types
diff --git a/test/TypeUtilsSpec.hs b/test/TypeUtilsSpec.hs
--- a/test/TypeUtilsSpec.hs
+++ b/test/TypeUtilsSpec.hs
@@ -593,7 +593,7 @@
           tdss <- mapM getDeclaredTypesRdr decls
           let tds = nub $ concat tdss
           return (tds)
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual $ map (\n -> (n, getGhcLoc $ GHC.nameSrcSpan n)) (res)) `shouldBe`
           "[(FreeAndDeclared.DeclareTypes.XList, (8, 1)),\n"++
@@ -621,8 +621,8 @@
           let r = hsFreeAndDeclaredPNsOld renamed
           rg <- hsFreeAndDeclaredPNs renamed
           return (r,rg,rr)
-      -- ((res,resg,rrr),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((res,resg,(FN fr,DN dr)),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((res,resg,rrr),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((res,resg,(FN fr,DN dr)),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       -- (showGhcQual _fff) `shouldBe` ""
 
@@ -724,7 +724,7 @@
           let b = head $ drop 4 $ hsBinds renamed
           rg <- hsFreeAndDeclaredPNs [b]
           return (b,rg)
-      ((bb,resg),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((bb,resg),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
 
       (showGhcQual bb) `shouldBe` "FreeAndDeclared.Declare.unD (FreeAndDeclared.Declare.B y) = y"
@@ -751,7 +751,7 @@
           let b = head $ drop 3 $ hsBinds renamed
           rg <- hsFreeAndDeclaredPNs [b]
           return (b,rg)
-      ((bb,resg),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((bb,resg),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual bb) `shouldBe` "FreeAndDeclared.Declare.unF (a FreeAndDeclared.Declare.:| b)\n  = (a, b)"
       -- (SYB.showData SYB.Renamer 0 bb) `shouldBe` ""
@@ -777,7 +777,7 @@
           let b = head $ drop 0 $ hsBinds renamed
           rg <- hsFreeAndDeclaredPNs [b]
           return (b,rg)
-      ((bb,resg),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((bb,resg),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
 
       (showGhcQual bb) `shouldBe` "FreeAndDeclared.DeclareRec.unR2\n  (FreeAndDeclared.DeclareRec.RCon {FreeAndDeclared.DeclareRec.r1 = a})\n  = a"
@@ -801,7 +801,7 @@
         comp = do
           r <- hsFreeAndDeclaredPNs renamed
           return r
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       -- Free Vars
       (showGhcQual $ map (\n -> (n, getGhcLoc $ GHC.nameSrcSpan n)) (fst res)) `shouldBe` "[]"
@@ -822,7 +822,7 @@
         comp = do
           r <- hsFreeAndDeclaredPNs [decl]
           return (r,decl)
-      ((res,d),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res,d),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual d) `shouldBe` "DupDef.Dd1.ff y\n  = y GHC.Num.+ zz\n  where\n      zz = 1"
       -- (SYB.showData SYB.Renamer 0 d) `shouldBe` ""
@@ -845,7 +845,7 @@
         comp = do
           r <- hsFreeAndDeclaredPNs $ hsBinds renamed
           return r
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       -- Declared Vars
       (showGhcQual $ map (\n -> (n, getGhcLoc $ GHC.nameSrcSpan n)) (snd res)) `shouldBe`
@@ -866,7 +866,7 @@
         comp = do
           r <- hsFreeAndDeclaredPNs renamed
           return r
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       -- Declared Vars
       (showGhcQual $ map (\n -> (n, getGhcLoc $ GHC.nameSrcSpan n)) (snd res)) `shouldBe`
@@ -896,7 +896,7 @@
         comp = do
           r <- hsFreeAndDeclaredPNs grhss
           return r
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
 
       -- Declared Vars
@@ -949,7 +949,7 @@
         comp = do
           r <- hsVisiblePNs tup tl1
           return r
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual $ res) `shouldBe` "[]"
 
@@ -970,7 +970,7 @@
         comp = do
          r <- hsVisiblePNs tl1 decl
          return (r)
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual res ) `shouldBe` "[z, ll]"
       -- (showGhcQual res2 ) `shouldBe` "[z, ll]"
@@ -991,7 +991,7 @@
         comp = do
           r <- hsVisiblePNs tl1 rhs
           return r
-      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((res),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual res) `shouldBe` "[ll]"
 
@@ -1012,8 +1012,8 @@
           let fvs = map (\b -> (showGhcQual b,getFreeVars [b])) (hsBinds renamed)
           let dvs = getDeclaredVars $ hsBinds renamed
           return (tl1,r,fvs,dvs)
-      -- ((tl,res,_f,d),_s) <- runRefactGhc comp $ initialState { rsModule = initRefactModule t }
-      ((tl,res,_f,d),_s) <- runRefactGhc comp $ initialLogOnState { rsModule = initRefactModule t }
+      -- ((tl,res,_f,d),_s) <- runRefactGhc comp $ initialState { rsModule = initRefactModule [] t }
+      ((tl,res,_f,d),_s) <- runRefactGhc comp $ initialLogOnState { rsModule = initRefactModule [] t }
 
       (showGhcQual tl) `shouldBe` "modu"
       -- (showGhcQual f) `shouldBe` ""
@@ -1063,8 +1063,8 @@
           let [decl] = definingDeclsRdrNames nameMap [n] declsp False False
           fds' <- hsVisibleDsRdr nameMap e decl
           return (fds')
-      -- ((fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe` "DN [a, b, GHC.Num.+]"
 
@@ -1088,8 +1088,8 @@
           let [decl] = definingDeclsRdrNames nameMap [n] declsp False False
           fds' <- hsVisibleDsRdr nameMap e decl
           return (fds')
-      -- ((fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe` "DN [x]"
 
@@ -1116,8 +1116,8 @@
           fds' <- hsVisibleDsRdr nameMap e rhs
           ffds <- hsFreeAndDeclaredGhc rhsr
           return (fds',ffds)
-      -- ((fds,_fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((fds,_fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show _fds) `shouldBe` "(FN [IdIn5.x, GHC.Num.+, y, z],DN [])"
       (show fds)  `shouldBe` "DN [GHC.Num.+, IdIn5.x, y, z]"
@@ -1139,8 +1139,8 @@
           fds' <- hsVisibleDsRdr nameMap ln parsed
           ffds <- hsFreeAndDeclaredGhc renamed
           return (fds',ffds)
-      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((fds,_fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((fds,_fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (show _fds) `shouldBe` "(FN [:, GHC.Num.+, GHC.Real.^, [], GHC.Base.++],"++
                               "DN [Renaming.D1.sumSquares, Renaming.D1.fringe, Renaming.D1.Tree, a,\n"++
@@ -1169,8 +1169,8 @@
         comp = do
           fds' <- hsVisibleDs e $  head $ hsBinds binds
           return (fds')
-      -- ((fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((fds),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe` "DN [a, b, GHC.Num.+]"
 
@@ -1192,7 +1192,7 @@
         comp = do
           fds' <- hsVisibleDs e $  head $ hsBinds binds
           return (fds')
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe` "DN [x]"
 
@@ -1213,7 +1213,7 @@
           fds' <- hsVisibleDs e rhs
           ffds <- hsFreeAndDeclaredGhc rhs
           return (fds',ffds)
-      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show _fds) `shouldBe` "(FN [IdIn5.x, GHC.Num.+, y, z],DN [])"
       (show fds) `shouldBe` "DN [GHC.Num.+, y, z]"
@@ -1232,7 +1232,7 @@
           fds' <- hsVisibleDs n renamed
           ffds <- hsFreeAndDeclaredGhc renamed
           return (fds',ffds)
-      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds,_fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show _fds) `shouldBe` "(FN [:, GHC.Num.+, GHC.Real.^, [], GHC.Base.++],"++
                              "DN [Renaming.D1.sumSquares, Renaming.D1.fringe, Renaming.D1.Tree, a,\n "++
@@ -1261,7 +1261,7 @@
         comp = do
           fds' <- hsFreeAndDeclaredGhc $  head $ hsBinds binds
           return (fds')
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe` "(FN [GHC.Num.+],DN [Visible.Simple.params])"
 
@@ -1286,7 +1286,7 @@
         comp = do
           fds' <- hsFreeAndDeclaredGhc $ lpat
           return (fds')
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe` "(FN [Visible.Simple.B],DN [x])"
 
@@ -1303,7 +1303,7 @@
         comp = do
           fds' <- hsFreeAndDeclaredGhc $ decls
           return (fds')
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe`
             "(FN [GHC.List.head, GHC.Base.$, GHC.List.zip],"++
@@ -1325,7 +1325,7 @@
         comp = do
           fds' <- hsFreeAndDeclaredGhc $ binds
           return (fds')
-      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe`
             "(FN [FreeAndDeclared.Binders.gfromJust,"++
@@ -1353,7 +1353,7 @@
           nm <- getRefactNameMap
           let fds' = hsFreeAndDeclaredRdr nm parsed
           return (fds')
-      ((fds),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((fds),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (show fds) `shouldBe`
             "(FN [System.IO.putStrLn, pr],"++
@@ -1438,7 +1438,7 @@
           let Just (GHC.L _ n) = locToName (17, 5) renamed
           topLevel <- isTopLevelPN n
           return (n,topLevel)
-      ((nf,tl),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nf,tl),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual nf) `shouldBe` "ff"
       tl `shouldBe` False
 
@@ -1451,7 +1451,7 @@
           topLevel <- isTopLevelPN n
           return (n,topLevel)
 
-      ((nf,tl),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nf,tl),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual nf) `shouldBe` "DupDef.Dd1.ff"
       tl `shouldBe` True
 
@@ -1536,7 +1536,7 @@
       let
         comp = do
          parseSourceFileGhc "./ScopeAndQual.hs"
-         putParsedModule t
+         -- putParsedModule t
          renamed <- getRefactRenamed
 
          logm $ "renamed=" ++ (SYB.showData SYB.Renamer 0 renamed) -- ++AZ++
@@ -1550,7 +1550,7 @@
          res1 <- isInScopeAndUnqualifiedGhc "sum" Nothing
          res2 <- isInScopeAndUnqualifiedGhc "L.sum" Nothing
          return (res1,res2,names,names2,sumSquares,ssUnqual,ctx)
-      ((r1,r2,ns,ns2,ss,ssu,_c),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r1,r2,ns,ns2,ss,ssu,_c),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (prettyprint ss) `shouldBe` "sumSquares"
       (showGhcQual ss) `shouldBe` "ScopeAndQual.sumSquares"
@@ -1575,7 +1575,7 @@
          name3 <- mkNewGhcName (Just (GHC.nameModule topLevel)) "baz"
 
          return (name1,name2,name3)
-      ((n1,n2,n3),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((n1,n2,n3),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       GHC.getOccString n1 `shouldBe` "foo"
       showGhcQual n1 `shouldBe` "foo"
@@ -1624,7 +1624,7 @@
          putRefactParsed parsed' emptyAnns
 
          return newBindings
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "DupDef.Dd1.toplevel"
       (sourceFromState s) `shouldBe` "module DupDef.Dd1 where\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nbar2 :: Integer -> Integer\nbar2 x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff y = y + zz\n  where\n    zz = 1\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\n"
 
@@ -1663,8 +1663,8 @@
 
          return (funBinding,declsToDup,declsp')
 
-      ((fb,dd,newb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((fb,dd,newb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((fb,dd,newb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((fb,dd,newb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "ff"
       (showGhcQual dd) `shouldBe` "[ff = 15]"
@@ -1693,7 +1693,7 @@
          putRefactParsed parsed' emptyAnns
 
          return declsp'
-      (nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      (nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "MoveDef.Md1.toplevel"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\ntoplevel :: Integer -> Integer\ntoplevel bar2 x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff :: Int -> Int\nff y = y + zz\n  where\n    zz = 1\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
@@ -1715,8 +1715,8 @@
          parsed' <- liftT $ replaceDecls parsed declsp'
          putRefactParsed parsed' emptyAnns
          return declsp'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "AddParams1.sq"
       (sourceFromState s) `shouldBe` "module AddParams1 where\n\nsq pow  0 = 0\nsq pow  z = z^2\n\nfoo = 3\n\n"
@@ -1739,7 +1739,7 @@
          putRefactParsed parsed' emptyAnns
 
          return declsp'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "AddParams1.foo"
       (sourceFromState s) `shouldBe` "module AddParams1 where\n\nsq  0 = 0\nsq  z = z^2\n\nfoo baz bar = 3\n\n"
@@ -1761,8 +1761,8 @@
          newBinding <- addActualParamsToRhs n [newName2] decl
 
          return (newBinding,decl)
-      ((nb,decl'),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,decl'),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,decl'),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,decl'),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual decl') `shouldBe` "sumSquares (x : xs)\n  = sq x + sumSquares xs\n  where\n      sq x = x ^ pow\n      pow = 2\nsumSquares [] = 0"
       (showGhcQual n) `shouldBe` "sq"
       (showGhcQual nb) `shouldBe` "sumSquares (x : xs)\n  = (sq bar2) x + sumSquares xs\n  where\n      sq x = x ^ pow\n      pow = 2\nsumSquares [] = 0"
@@ -1787,7 +1787,7 @@
          newBinding <- addActualParamsToRhs n [newName1,newName2,newName3] decl
 
          return (newBinding,decl)
-      ((nb,decl'),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,decl'),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual decl') `shouldBe` "fun x y z\n  = inc addthree\n  where\n      inc a = a + 1\n      addthree = x + y + z"
       (showGhcQual n) `shouldBe` "addthree"
       (showGhcQual nb) `shouldBe` "fun x y z\n  = inc (addthree x1 y1 z1)\n  where\n      inc a = a + 1\n      addthree = x + y + z"
@@ -1808,8 +1808,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "MoveDef.Md1a.ff"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1a where\n\ndata D = A | B String | C\n\nff :: Int -> Int\n\nl = 1\n\n"
@@ -1826,8 +1826,8 @@
          (parsed',_removedDecl,_removedSig) <- rmDecl n False parsed
          putRefactParsed parsed' emptyAnns
          return parsed'
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "MoveDef.Md1b.ff"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1b where\n\ndata D = A | C\n\nff :: Int -> Int\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\n"
@@ -1845,8 +1845,8 @@
          putRefactParsed parsed' emptyAnns
          logDataWithAnns "parsed'" parsed'
          return parsed'
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "MoveDef.Md1.ff"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff :: Int -> Int\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
@@ -1864,8 +1864,8 @@
          (newDecls,_removedDecl,_removedSig) <- rmDecl n True parsed
          putRefactParsed newDecls emptyAnns
          return newDecls
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "MoveDef.Md1.ff"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
@@ -1885,8 +1885,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "sq"
       -- (showToks $ take 20 $ toksFromState s) `shouldBe` ""
@@ -1907,8 +1907,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "zz"
       (sourceFromState s) `shouldBe` "module RmDecl3 where\n\n-- Remove last declaration from a where clause, where should disappear too\nff y = y + zz\n\n-- EOF\n"
@@ -1929,8 +1929,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "zz"
       (sourceFromState s) `shouldBe` "{-# LANGUAGE FlexibleContexts #-}\nmodule RmDecl4 where\n\n-- Remove first declaration from a where clause, rest should still be indented\nff y = y + zz ++ xx\n  where\n    xx = 2\n\n-- EOF\n"
@@ -1950,8 +1950,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "pow"
       (sourceFromState s) `shouldBe` "module Demote.LetIn1 where\n\n--A definition can be demoted to the local 'where' binding of a friend declaration,\n--if it is only used by this friend declaration.\n\n--Demoting a definition narrows down the scope of the definition.\n--In this example, demote the local  'pow' to 'sq'\n--This example also aims to test the demoting a local declaration in 'let'.\n\nsumSquares x y = let sq 0=0\n                     sq z=z^pow\n                 in sq x + sq y\n\n\nanotherFun 0 y = sq y\n     where  sq x = x^2\n\n  "
@@ -1970,8 +1970,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "sq"
       (sourceFromState s) `shouldBe` "module Demote.LetIn2 where\n\n--A definition can be demoted to the local 'where' binding of a friend declaration,\n--if it is only used by this friend declaration.\n\n--Demoting a definition narrows down the scope of the definition.\n--In this example, demote the local  'pow' will fail.\n\nsumSquares x y = let pow=2\n                 in sq x + sq y +pow\n\n\nanotherFun 0 y = sq y\n     where  sq x = x^2\n\n  "
@@ -1989,8 +1989,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "Demote.WhereIn3.sq"
       (sourceFromState s) `shouldBe` "module Demote.WhereIn3 where\n\n--A definition can be demoted to the local 'where' binding of a friend declaration,\n--if it is only used by this friend declaration.\n\n--Demoting a definition narrows down the scope of the definition.\n--In this example, demote the top level 'sq' to 'sumSquares'\n--In this case (there are multi matches), the parameters are not folded after demoting.\n\nsumSquares x y = sq p x + sq p y\n         where p=2  {-There is a comment-}\n\nsq :: Int -> Int -> Int\n\n{- foo bar -}\nanotherFun 0 y = sq y\n     where  sq x = x^2\n"
 
@@ -2008,8 +2008,8 @@
          putRefactParsed parsed' emptyAnns
 
          return parsed'
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "sq"
       (sourceFromState s) `shouldBe` "module LiftOneLevel.D1 where\n\n{-lift 'sq' to top level. This refactoring\naffects module 'D1' and 'C1' -}\n\nsumSquares (x:xs) = sq x + sumSquares xs\n  where\n     pow =2\n\nsumSquares [] = 0\n\nmain = sumSquares [1..4]\n"
 
@@ -2027,8 +2027,8 @@
          (renamed',sigRemoved) <- rmTypeSig n parsed
          putRefactParsed renamed' emptyAnns
          return (renamed',sigRemoved)
-      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((_nb,os),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((_nb,os),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "MoveDef.Md1.ff"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff y = y + zz\n  where\n    zz = 1\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
@@ -2048,8 +2048,8 @@
          putRefactParsed parsed2 emptyAnns
 
          return parsed2
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "Demote.WhereIn3.sq"
       (sourceFromState s) `shouldBe` "module Demote.WhereIn3 where\n\n--A definition can be demoted to the local 'where' binding of a friend declaration,\n--if it is only used by this friend declaration.\n\n--Demoting a definition narrows down the scope of the definition.\n--In this example, demote the top level 'sq' to 'sumSquares'\n--In this case (there are multi matches), the parameters are not folded after demoting.\n\nsumSquares x y = sq p x + sq p y\n         where p=2  {-There is a comment-}\n\n{- foo bar -}\nanotherFun 0 y = sq y\n     where  sq x = x^2\n"
 
@@ -2066,8 +2066,8 @@
          (renamed',_removedSig) <- rmTypeSig n parsed
          putRefactParsed renamed' emptyAnns
          return renamed'
-      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- (_nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      (_nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "ff"
       -- (showToks $ take 20 $ toksFromState s) `shouldBe` ""
@@ -2085,7 +2085,7 @@
          (renamed',removedSig) <- rmTypeSig b parsed
          putRefactParsed renamed' emptyAnns
          return (renamed',removedSig)
-      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (exactPrintFromState s (fromJust os)) `shouldBe` "\n\nb::Int->Integer->Char"
       (showGhcQual b) `shouldBe` "TypeSigs.b"
       (sourceFromState s) `shouldBe` "module TypeSigs where\n\nsq,anotherFun :: Int -> Int\nsq 0 = 0\nsq z = z^2\n\nanotherFun x = x^2\n\na,c::Int->Integer->Char\n\na x y = undefined\nb x y = undefined\nc x y = undefined\n\n"
@@ -2102,8 +2102,8 @@
          (renamed',removedSig) <- rmTypeSig n parsed
          putRefactParsed renamed' emptyAnns
          return (renamed',removedSig)
-      -- ((_nb,os),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((_nb,os),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       -- putStrLn $ "anntree\n" ++ showAnnDataFromState s
       (exactPrintFromState s (fromJust os)) `shouldBe` "\n\nsq :: Int -> Int"
       (showGhcQual n) `shouldBe` "TypeSigs.sq"
@@ -2122,8 +2122,8 @@
          (parsed',removedSig) <- rmTypeSig n parsed
          putRefactParsed parsed' emptyAnns
          return (parsed',removedSig)
-      -- ((_nb,os),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((_nb,os),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((_nb,os),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "WhereIn7.sq"
       (exactPrintFromState s (fromJust os)) `shouldBe` "\n\nsq :: Int -> Int"
       (sourceFromState s) `shouldBe` "module WhereIn7 where\n\n--A definition can be demoted to the local 'where' binding of a friend declaration,\n--if it is only used by this friend declaration.\n\n--Demoting a definition narrows down the scope of the definition.\n--In this example, demote the top level 'sq' to 'sumSquares'\n--This example also aims to test the split of type signature.\n\nsumSquares x y = sq x + sq y\n\nanotherFun :: Int -> Int\nsq 0 = 0\nsq z = z^pow\n   where  pow=2\n\nanotherFun x = x^2\n "
@@ -2141,8 +2141,8 @@
          let (Just (GHC.L ss _)) = removedSig
          oldSigToks <- getToksForSpan ss
          return (renamed',removedSig,oldSigToks)
-      -- ((nb,os,ot),s) <- runRefactGhc comp $ initialState { rsModule = initRefactModule t }
-      ((nb,os,ot),s) <- runRefactGhc comp $ initialLogOnState { rsModule = initRefactModule t }
+      -- ((nb,os,ot),s) <- runRefactGhc comp $ initialState { rsModule = initRefactModule [] t }
+      ((nb,os,ot),s) <- runRefactGhc comp $ initialLogOnState { rsModule = initRefactModule [] t }
       (showGhcQual n) `shouldBe` "tup"
       -- (showToks $ take 20 $ toksFromState s) `shouldBe` ""
       (sourceFromState s) `shouldBe` "module LiftToToplevel.PatBindIn1 where\n\n --A definition can be lifted from a where or let into the surrounding binding group.\n --Lifting a definition widens the scope of the definition.\n\n --In this example, lift 'tup' defined in 'foo'\n --This example aims to test renaming and the lifting of type signatures.\n\n main :: Int\n main = foo 3\n\n foo :: Int -> Int\n foo x = h + t + (snd tup)\n       where\n       \n       \n\n       tup@(h,t) = head $ zip [1..10] [3..15]\n "
@@ -2163,8 +2163,8 @@
          parsed' <- addDecl parsed Nothing ([decl],Just declAnns)
          putRefactParsed parsed' emptyAnns
          return parsed'
-      (nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- (nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      (nb,s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- (nb,s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\nnn = n2\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff :: Int -> Int\nff y = y + zz\n  where\n    zz = 1\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
       (unspace $ showGhcQual nb) `shouldBe` unspace "module MoveDef.Md1 where\nnn = n2\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\nc, d :: Integer\nc = 7\nd = 9\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h, t)\n = head $ zip [1 .. 10] [3 .. ff]\n where\n ff :: Int\n ff = 15\ndata D = A | B String | C\nff :: Int -> Int\nff y\n = y + zz\n where\n zz = 1\nl z = let ll = 34 in ll + z\ndd q\n = do { let ss = 5;\n return (ss + q) }\nzz1 a = 1 + toplevel a\ntlFunc :: Integer -> Integer\ntlFunc x = c * x"
@@ -2181,7 +2181,7 @@
          parsed' <- addDecl parsed Nothing ([sig,decl],Just $ mergeAnns sigAnns declAnns)
          putRefactParsed parsed' emptyAnns
          return (sig,parsed')
-      ((_hs,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_hs,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\nnn :: Int\nnn = 2\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff :: Int -> Int\nff y = y + zz\n  where\n    zz = 1\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
       (unspace $ showGhcQual nb) `shouldBe` unspace "module MoveDef.Md1 where\nnn :: Int\nnn = 2\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\nc, d :: Integer\nc = 7\nd = 9\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h, t)\n = head $ zip [1 .. 10] [3 .. ff]\n where\n ff :: Int\n ff = 15\ndata D = A | B String | C\nff :: Int -> Int\nff y\n = y + zz\n where\n zz = 1\nl z = let ll = 34 in ll + z\ndd q\n = do { let ss = 5;\n return (ss + q) }\nzz1 a = 1 + toplevel a\ntlFunc :: Integer -> Integer\ntlFunc x = c * x"
 
@@ -2198,8 +2198,8 @@
          parsed' <- addDecl parsed (Just n) ([decl],Just declAnns)
          putRefactParsed parsed' emptyAnns
          return (n,parsed')
-      ((n,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((n,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((n,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((n,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "MoveDef.Md1.ff"
       (sourceFromState s) `shouldBe` "module MoveDef.Md1 where\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff :: Int -> Int\nff y = y + zz\n  where\n    zz = 1\n\nnn = nn2\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
       (unspace $ showGhcQual nb) `shouldBe` unspace "module MoveDef.Md1 where\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\nc, d :: Integer\nc = 7\nd = 9\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h, t)\n = head $ zip [1 .. 10] [3 .. ff]\n where\n ff :: Int\n ff = 15\ndata D = A | B String | C\nff :: Int -> Int\nff y\n = y + zz\n where\n zz = 1\nnn = nn2\nl z = let ll = 34 in ll + z\ndd q\n = do { let ss = 5;\n return (ss + q) }\nzz1 a = 1 + toplevel a\ntlFunc :: Integer -> Integer\ntlFunc x = c * x"
@@ -2219,7 +2219,7 @@
          parsed' <- addDecl parsed (Just n) ([sig,decl],Just $ mergeAnns sigAnns declAnns)
          putRefactParsed parsed' emptyAnns
          return (n,parsed')
-      ((nn,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nn,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual nn) `shouldBe` "MoveDef.Md1.ff"
       (sourceFromState s) `shouldBe`"module MoveDef.Md1 where\n\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff :: Int -> Int\nff y = y + zz\n  where\n    zz = 1\n\nnn :: Int\nnn = nn2\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\nzz1 a = 1 + toplevel a\n\n-- General Comment\n-- |haddock comment\ntlFunc :: Integer -> Integer\ntlFunc x = c * x\n-- Comment at end\n\n\n"
       (unspace $ showGhcQual nb) `shouldBe` unspace "module MoveDef.Md1 where\ntoplevel :: Integer -> Integer\ntoplevel x = c * x\nc, d :: Integer\nc = 7\nd = 9\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h, t)\n = head $ zip [1 .. 10] [3 .. ff]\n where\n ff :: Int\n ff = 15\ndata D = A | B String | C\nff :: Int -> Int\nff y\n = y + zz\n where\n zz = 1\nnn :: Int\nnn = nn2\nl z = let ll = 34 in ll + z\ndd q\n = do { let ss = 5;\n return (ss + q) }\nzz1 a = 1 + toplevel a\ntlFunc :: Integer -> Integer\ntlFunc x = c * x"
@@ -2248,8 +2248,8 @@
          logm $ "test:addDecl done"
 
          return (tlDecl,newDecl)
-      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual tl) `shouldBe` "toplevel x = c * x"
       (exactPrintFromState s nb) `shouldBe` "\ntoplevel x = c * x\n  where\n    nn = nn2"
       (showGhcQual nb)           `shouldBe` "toplevel x\n  = c * x\n  where\n      nn = nn2"
@@ -2275,8 +2275,8 @@
          newDecl <- addDecl tlDecl Nothing ([sig,decl],Just $ mergeAnns sigAnns declAnns)
 
          return (tlDecl,newDecl)
-      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual tl) `shouldBe` "toplevel x = c * x"
       -- putStrLn (showAnnDataItemFromState s nb)
       (exactPrintFromState s nb) `shouldBe` "\ntoplevel x = c * x\n  where\n    nn :: Int\n    nn = nn2"
@@ -2302,7 +2302,7 @@
          newDecl <- addDecl tlDecl Nothing ([decl],Just declAnns)
 
          return (tlDecl,newDecl)
-      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual tl) `shouldBe` "toplevel x = c * x"
       (exactPrintFromState s nb) `shouldBe` "\ntoplevel x = c * x\n  where\n    nn = nn2"
       (showGhcQual nb) `shouldBe` "toplevel x\n  = c * x\n  where\n      nn = nn2"
@@ -2328,8 +2328,8 @@
          newDecl <- addDecl tlDecl Nothing ([decl],Just declAnns)
 
          return (tlDecl,newDecl)
-      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual tl) `shouldBe` "toplevel x\n  = c * x * b\n  where\n      b = 3"
       (exactPrintFromState s nb) `shouldBe` "\ntoplevel x = c * x * b\n  where\n    nn = nn2\n\n    b = 3"
       (showGhcQual nb) `shouldBe` "toplevel x\n  = c * x * b\n  where\n      b = 3\n      nn = nn2"
@@ -2356,7 +2356,7 @@
          newDecl <- addDecl tlDecl Nothing ([sig,decl],Just $ mergeAnns sigAnns declAnns)
 
          return (tlDecl,newDecl)
-      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual tl) `shouldBe` "toplevel x\n  = c * x * b\n  where\n      b = 3"
       (exactPrintFromState s nb) `shouldBe` "\ntoplevel x = c * x * b\n  where\n    nn :: Int\n    nn = nn2\n\n    b = 3"
       (showGhcQual nb) `shouldBe` "toplevel x\n  = c * x * b\n  where\n      b = 3\n      nn = nn2\n      nn :: Int"
@@ -2389,8 +2389,8 @@
          newDecl <- addDecl tlDecl Nothing ([sqSigDecl,sqDecl],Nothing)
 
          return (sqSig,sqDecl,tlDecl,afDecl,newDecl)
-      -- ((sigs,_sd,tl,aa,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
-      ((sigs,_sd,tl,aa,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      -- ((sigs,_sd,tl,aa,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
+      ((sigs,_sd,tl,aa,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual sigs) `shouldBe` "sq :: Int -> Int -> Int"
       (showGhcQual tl) `shouldBe` "sumSquares x y\n  = sq p x + sq p y\n  where\n      p = 2"
       (showGhcQual aa) `shouldBe` "anotherFun 0 y\n  = sq y\n  where\n      sq x = x ^ 2"
@@ -2419,7 +2419,7 @@
          newDecl <- addDecl tlDecl Nothing ([yDecl],Nothing)
 
          return (yDecl,tlDecl,newDecl)
-      r <- catchException $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      r <- catchException $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       r `shouldBe` Just  "addDecl:Cannot add a local decl to a FunBind with multiple matches"
 
     -- -------------------------------------------
@@ -2443,8 +2443,8 @@
          newDecl <- addDecl tlDecl Nothing ([decl],Just declAnns)
 
          return (tlDecl,newDecl)
-      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((tl,nb),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((tl,nb),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual tl) `shouldBe` "tup@(h, t) = (x, 1)"
       (exactPrintFromState s nb) `shouldBe` "\n\ntup@(h,t) = (x,1)\n  where\n    nn = nn2"
       (showGhcQual nb) `shouldBe` "tup@(h, t)\n  = (x, 1)\n  where\n      nn = nn2"
@@ -2465,7 +2465,7 @@
          return (new,newName,n')
       let
 
-      ((nb,nn,n),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,nn,n),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual (n,nn)) `shouldBe` "(DupDef.Dd1.toplevel, bar2)"
       (sourceFromState s) `shouldBe` "module DupDef.Dd1 where\n\nbar2 :: Integer -> Integer\nbar2 x = c * x\n\nc,d :: Integer\nc = 7\nd = 9\n\n-- Pattern bind\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h,t) = head $ zip [1..10] [3..ff]\n  where\n    ff :: Int\n    ff = 15\n\ndata D = A | B String | C\n\nff y = y + zz\n  where\n    zz = 1\n\nl z =\n  let\n    ll = 34\n  in ll + z\n\ndd q = do\n  let ss = 5\n  return (ss + q)\n\n"
       (showGhcQual nb) `shouldBe` "module DupDef.Dd1 where\nbar2 :: Integer -> Integer\nbar2 x = c * x\nc, d :: Integer\nc = 7\nd = 9\ntup :: (Int, Int)\nh :: Int\nt :: Int\ntup@(h, t)\n  = head $ zip [1 .. 10] [3 .. ff]\n  where\n      ff :: Int\n      ff = 15\ndata D = A | B String | C\nff y\n  = y + zz\n  where\n      zz = 1\nl z = let ll = 34 in ll + z\ndd q\n  = do { let ss = 5;\n         return (ss + q) }"
@@ -2488,7 +2488,7 @@
          putRefactParsed parsed' emptyAnns
          return (new,newName,decl,n')
       let
-      ((nb,nn,d,n),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,nn,d,n),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual d) `shouldBe` "sumSquares x y\n  = sq p x + sq p y\n  where\n      p = 2"
       (showGhcQual (n,nn)) `shouldBe` "(p, p_1)"
       (sourceFromState s) `shouldBe` "module Demote.WhereIn4 where\n\n--A definition can be demoted to the local 'where' binding of a friend declaration,\n--if it is only used by this friend declaration.\n\n--Demoting a definition narrows down the scope of the definition.\n--In this example, demote the top level 'sq' to 'sumSquares'\n--In this case (there is single matches), if possible,\n--the parameters will be folded after demoting and type sigature will be removed.\n\nsumSquares x y = sq p_1 x + sq p_1 y\n         where p_1=2  {-There is a comment-}\n\nsq::Int->Int->Int\nsq pow z = z^pow  --there is a comment\n\nanotherFun 0 y = sq y\n     where  sq x = x^2\n\n"
@@ -2515,8 +2515,8 @@
          return (new,newName)
       let
 
-      ((nb,nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual (n,nn)) `shouldBe` "(TokenTest.foo, bar2)"
       (sourceFromState s) `shouldBe` "module TokenTest where\n\n-- Test new style token manager\n\nbob a b = x\n  where x = 3\n\nbib a b = x\n  where\n    x = 3\n\n\nbab a b =\n  let bar = 3\n  in     b + bar -- ^trailing comment\n\n\n-- leading comment\nbar2 x y =\n  do c <- getChar\n     return c\n\n\n\n\n"
       (showGhcQual nb) `shouldBe` "bar2 x y\n  = do { c <- getChar;\n         return c }"
@@ -2544,7 +2544,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "TokenTest.foo"
       (sourceFromState s) `shouldBe` "module TokenTest where\n\n-- Test new style token manager\n\nbob a b = x\n  where x = 3\n\nbib a b = x\n  where\n    x = 3\n\n\nbab a b =\n  let bar = 3\n  in     b + bar -- ^trailing comment\n\n\n-- leading comment\nbar2 x y =\n  do c <- getChar\n     return c\n\n\n\n\n"
@@ -2569,7 +2569,7 @@
          return (new,newName)
       let
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "Field1.pointx"
       (sourceFromState s) `shouldBe` "module Field1 where\n\n--Rename field name 'pointx' to 'pointx1'\n\ndata Point = Pt {pointx1, pointy :: Float}\n\nabsPoint :: Point -> Float\nabsPoint p = sqrt (pointx1 p * pointx1 p +\n                  pointy p * pointy p)\n\n"
@@ -2595,8 +2595,8 @@
          return (new,newName)
       let
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "Field1.Point"
       (sourceFromState s) `shouldBe` "module Field1 where\n\n--Rename field name 'pointx' to 'pointx1'\n\ndata NewPoint = Pt {pointx, pointy :: Float}\n\nabsPoint :: NewPoint -> Float\nabsPoint p = sqrt (pointx p * pointx p +\n                  pointy p * pointy p)\n\n"
       (unspace $ showGhcQual nb) `shouldBe` "module Field1 where\ndata NewPoint = Pt {pointx, pointy :: Float}\nabsPoint :: NewPoint -> Float\nabsPoint p = sqrt (pointx p * pointx p + pointy p * pointy p)"
@@ -2619,7 +2619,7 @@
          return (new,newName)
       let
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "LocToName.sumSquares"
       (sourceFromState s) `shouldBe` "module LocToName where\n\n{-\n\n\n\n\n\n\n\n\n-}\n\n\n\n\n\n\n\nnewPoint (x:xs) = x ^2 + newPoint xs\n    -- where sq x = x ^pow \n    --       pow = 2\n\nnewPoint [] = 0\n"
       (unspace $ showGhcQual nb) `shouldBe` "module LocToName where\nnewPoint (x : xs) = x ^ 2 + newPoint xs\nnewPoint [] = 0"
@@ -2643,8 +2643,8 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,_nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,_nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n) `shouldBe` "LocToName.sumSquares"
       (unspace $ showGhcQual nb) `shouldBe` "module LocToName where\nLocToName.newPoint (x : xs) = x ^ 2 + LocToName.newPoint xs\nLocToName.newPoint [] = 0"
       (sourceFromState s) `shouldBe` "module LocToName where\n\n{-\n\n\n\n\n\n\n\n\n-}\n\n\n\n\n\n\n\nnewPoint (x:xs) = x ^2 + LocToName.newPoint xs\n    -- where sq x = x ^pow \n    --       pow = 2\n\nnewPoint [] = 0\n"
@@ -2669,7 +2669,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       -- (showGhcQual $ sourceTreeFromState s) `shouldBe` ""
       (sourceFromState s) `shouldBe` "module LayoutIn2 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'list' to 'ls'.\n\nsilly :: [Int] -> Int\nsilly ls = case ls of  (1:xs) -> 1\n--There is a comment\n                       (2:xs)\n                         | x < 10    -> 4  where  x = last xs\n                       otherwise -> 12\n\n"
       (unspace $ showGhcQual nb) `shouldBe` "module LayoutIn2 where\nsilly :: [Int] -> Int\nsilly ls\n = case ls of {\n (1 : xs) -> 1\n (2 : xs)\n | x < 10 -> 4\n where\n x = last xs\n otherwise -> 12 }"
@@ -2693,8 +2693,8 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,_nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,_nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "Data.Foldable.sum"
       (sourceFromState s) `shouldBe` "module ScopeAndQual where\n\nimport qualified Data.List as L\nimport Prelude hiding (mySum)\n\nmain :: IO ()\nmain = putStrLn (show $ L.mySum [1,2,3])\n\nsum a b = a + b\n\nsumSquares xs = L.mySum $ map (\\x -> x*x) xs\n\nmySumSq = sumSquares\n"
@@ -2720,8 +2720,8 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,_nn),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,_nn),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "Renaming.C7.myFringe"
       (sourceFromState s) `shouldBe` "module Renaming.C7(LocToName.myNewFringe)  where\n\nimport Renaming.D7\n\nmyNewFringe:: Tree a -> [a]\nmyNewFringe (Leaf x ) = [x]\nmyNewFringe (Branch left right) = LocToName.myNewFringe left ++ fringe right\n\n\n\n\n"
@@ -2746,7 +2746,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "list"
       (sourceFromState s) `shouldBe` "module LayoutIn2 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'list' to 'ls'.\n\nsilly :: [Int] -> Int\nsilly ls = case ls of  (1:xs) -> 1\n--There is a comment\n                       (2:xs)\n                         | x < 10    -> 4  where  x = last xs\n                       otherwise -> 12\n\n"
@@ -2773,7 +2773,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "list"
       (sourceFromState s) `shouldBe` "module LayoutIn2 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'list' to 'ls'.\n\nsilly :: [Int] -> Int\nsilly listlonger = case listlonger of  (1:xs) -> 1\n            --There is a comment\n                                       (2:xs)\n                                         | x < 10    -> 4  where  x = last xs\n                                       otherwise -> 12\n\n"
@@ -2799,7 +2799,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "ioFun"
       (sourceFromState s) `shouldBe` "module LayoutIn4 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'ioFun' to  'io'\n\nmain = io \"hello\" where io s= do  let  k = reverse s\n--There is a comment\n                                  s <- getLine\n                                  let  q = (k ++ s)\n                                  putStr q\n                                  putStr \"foo\"\n\n"
@@ -2825,7 +2825,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "ioFun"
       (sourceFromState s) `shouldBe` "module LayoutIn4 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'ioFun' to  'io'\n\nmain = ioFunLong \"hello\" where ioFunLong s= do  let  k = reverse s\n         --There is a comment\n                                                s <- getLine\n                                                let  q = (k ++ s)\n                                                putStr q\n                                                putStr \"foo\"\n\n"
@@ -2850,7 +2850,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "sq"
       (sourceFromState s) `shouldBe` "module LayoutIn1 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'sq' to 'square'.\n\nsumSquares x y= q x + q y where q x= x^pow\n--There is a comment.\n                                pow=2\n"
@@ -2876,7 +2876,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "sq"
       (sourceFromState s) `shouldBe` "module LayoutIn1 where\n\n--Layout rule applies after 'where','let','do' and 'of'\n\n--In this Example: rename 'sq' to 'square'.\n\nsumSquares x y= square x + square y where square x= x^pow\n          --There is a comment.\n                                          pow=2\n"
@@ -2901,7 +2901,7 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "xxx"
       (sourceFromState s) `shouldBe` "module LayoutLet1 where\n\n-- Simple let expression, rename xxx to something longer or shorter\n-- and the let/in layout should adjust accordingly\n\nfoo x = let a = 1\n            b = 2\n        in x + a + b\n\n"
@@ -2927,8 +2927,8 @@
 
          return (new,newName)
 
-      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,_nn),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,nn),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "xxx"
       (sourceFromState s) `shouldBe` "module LayoutLet1 where\n\n-- Simple let expression, rename xxx to something longer or shorter\n-- and the let/in layout should adjust accordingly\n\nfoo xxxlong = let a = 1\n                  b = 2\n              in xxxlong + a + b\n\n"
@@ -2954,8 +2954,8 @@
 
          return (new,newName)
 
-      ((nb,nn),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((nb,nn),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((nb,nn),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((nb,nn),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual (n,nn)) `shouldBe` "(xxx, xxxlong)"
       (sourceFromState s) `shouldBe` "module LayoutLet2 where\n\n-- Simple let expression, rename xxx to something longer or shorter\n-- and the let/in layout should adjust accordingly\n-- In this case the tokens for xxx + a + b should also shift out\n\nfoo xxxlong = let a = 1\n                  b = 2 in xxxlong + a + b\n\n"
@@ -2982,8 +2982,8 @@
 
          return (new,newName)
 
-      ((_nb,nn),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((_nb,nn),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((_nb,nn),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((_nb,nn),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual (n,nn)) `shouldBe` "(Renaming.RenameInExportedType.NT, NewType)"
       (sourceFromState s) `shouldBe` "module Renaming.RenameInExportedType\n  (\n  MyType (NewType)\n  ) where\n\ndata MyType = MT Int | NewType\n\n\n"
@@ -3004,7 +3004,7 @@
          return ()
       let
 
-      (_,s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      (_,s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual n) `shouldBe` "Renaming.C7.myFringe"
       (sourceFromState s) `shouldBe` "module Renaming.C7(Renaming.C7.myFringe)  where\n\nimport Renaming.D7\n\nmyFringe:: Tree a -> [a]\nmyFringe (Leaf x ) = [x]\nmyFringe (Branch left right) = Renaming.C7.myFringe left ++ fringe right\n\n\n\n\n"
@@ -3031,7 +3031,7 @@
              -- res = findEntity' ln duplicatedDecls
 
          return (res,res2,duplicatedDecls,ln)
-      ((r,r2,d,_l),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,r2,d,_l),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual d) `shouldBe` "[DupDef.Dd1.toplevel x = DupDef.Dd1.c GHC.Num.* x]"
       (showGhcQual _l) `shouldBe` "DupDef.Dd1.toplevel"
       ("1" ++ show r) `shouldBe` "1True"
@@ -3058,7 +3058,7 @@
              res2 = findEntity  n duplicatedDecls
 
          return (res,res2,duplicatedDecls,ln)
-      ((r,r2,d,_l),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,r2,d,_l),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual d) `shouldBe` "[DupDef.Dd1.dd q\n   = do { let ss = 5;\n"++
                              "          GHC.Base.return (ss GHC.Num.+ q) }]"
       (showGhcQual _l) `shouldBe` "ss"
@@ -3087,7 +3087,7 @@
              -- res = findEntity' ln duplicatedDecls
 
          return (res,duplicatedDecls,ln)
-      ((r,d,_l),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,d,_l),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual d) `shouldBe` "[DupDef.Dd1.toplevel x = DupDef.Dd1.c GHC.Num.* x]"
       ("1" ++ show r) `shouldBe` "1False"
 
@@ -3184,7 +3184,7 @@
          exSumSquares <- isExported sumSquares
 
          return (myFringe,exMyFring,sumSquares,exSumSquares)
-      ((mf,emf,ss,ess),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t}) testOptions
+      ((mf,emf,ss,ess),_s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t}) testOptions
 
       (showGhcQual mf) `shouldBe` "Renaming.B1.myFringe"
       emf `shouldBe` True
@@ -3217,8 +3217,8 @@
          putRefactParsed res emptyAnns
 
          return (res,renamed2)
-      ((_r,_r2),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t1}) testOptions
-      -- ((_r,_r2),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t1}) testOptions
+      ((_r,_r2),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t1}) testOptions
+      -- ((_r,_r2),s) <- ct $ runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t1}) testOptions
 
       (sourceFromState s) `shouldBe` "module DupDef.Dd2 where\n\nimport DupDef.Dd1 hiding (n1,n2)\n\n\nf2 x = ff (x+1)\n\nmm = 5\n\n\n"
 
@@ -3247,7 +3247,7 @@
          res  <- addHiding modName parsed2 [n1,n2]
 
          return (res,renamed2)
-      ((_r,_r2),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t1}) testOptions
+      ((_r,_r2),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t1}) testOptions
       (sourceFromState s) `shouldBe` "module DupDef.Dd3 where\n\nimport DupDef.Dd1 hiding (dd,n1,n2)\n\n\nf2 x = ff (x+1)\n\nmm = 5\n\n\n"
 
   -- ---------------------------------------------
@@ -3306,7 +3306,7 @@
           let res = usedWithoutQualR name parsed
           return (res,n,name)
 
-      ((r,n1,n2),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,n1,n2),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (GHC.getOccString n2) `shouldBe` "zip"
       (showGhcQual n1) `shouldBe` "GHC.List.zip"
@@ -3325,7 +3325,7 @@
           let Just (GHC.L _ namep) = locToRdrName (36,12) parsed
           let res = usedWithoutQualR name parsed
           return (res,namep,name,n)
-      ((r,np,n1,n2),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,np,n1,n2),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (myShow np) `shouldBe` "Qual:G:gshow"
       (myShow $ GHC.getRdrName n1) `shouldBe` "Exact:Data.Generics.Text.gshow"
@@ -3445,7 +3445,7 @@
 
           return (res,decls,tl,name)
 
-      ((r,d,n1,n2),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((r,d,n1,n2),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n1) `shouldBe` "MoveDef.Demote.toplevel"
       (showGhcQual n2) `shouldBe` "MoveDef.Demote.c"
       (showGhcQual d) `shouldBe` "[toplevel x = c * x]"
@@ -3470,8 +3470,8 @@
 
           return (decls',decls,tl,name)
 
-      ((r,d,n1,n2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((r,d,n1,n2),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((r,d,n1,n2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((r,d,n1,n2),s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
       (showGhcQual n1) `shouldBe` "Demote.WhereIn4.sumSquares"
       (showGhcQual n2) `shouldBe` "p"
       (showGhcQual d) `shouldBe` "sumSquares x y\n  = sq p x + sq p y\n  where\n      p = 2"
@@ -3503,7 +3503,7 @@
          putRefactParsed res emptyAnns
 
          return (res,renamed2)
-      ((_r,_r2),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_r,_r2),s) <- ct $ runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (sourceFromState s) `shouldBe` "module DupDef.Dd2 where\n\nimport DupDef.Dd1\nimport Data.List\n\n\nf2 x = ff (x+1)\n\nmm = 5\n\n\n"
 
     -- ---------------------------------
@@ -3521,7 +3521,7 @@
          putRefactParsed res emptyAnns
 
          return (res,renamed1)
-      ((_r,_r2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_r,_r2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (sourceFromState s) `shouldBe` "module Simplest where\nimport Data.List\n\n\nsimple x = x\n"
 
     -- ---------------------------------
@@ -3538,7 +3538,7 @@
          putRefactParsed res emptyAnns
 
          return (res,renamed1)
-      ((_r,_r2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_r,_r2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (sourceFromState s) `shouldBe` "module JustImports where\n\nimport Data.Maybe\nimport Data.List\n"
 
     -- ---------------------------------
@@ -3555,7 +3555,7 @@
          putRefactParsed res emptyAnns
 
          return (res,renamed1)
-      ((_r,_r2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_r,_r2),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       (sourceFromState s) `shouldBe` "module Empty where\nimport Data.List\n\n"
 
@@ -3577,7 +3577,7 @@
          putRefactParsed res emptyAnns
 
          return (res)
-      ((_r),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_r),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
 
       -- This is the correct behavior. If the import doesn't have an import list, creating
       -- one for an item effectively reduces the imported interface.
@@ -3620,7 +3620,7 @@
          res  <- addItemsToImport modName parsed [itemName]
          putRefactParsed res emptyAnns
          return (res)
-      ((_r),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((_r),s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
       (sourceFromState s) `shouldBe` "module SelectivelyImports where\n\nimport Data.Maybe (fromJust,isJust)\n\n__ = id\n"
 
 {- -- test after properly inserting conditional identifier
@@ -3771,8 +3771,8 @@
               (Just name) = locToName    (5,1) renamed
           nname <- rdrName2Name rdr
           return (rdr,name,nname)
-      ((r,n,nn),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((r,n,nn),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((r,n,nn),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((r,n,nn),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual (r,n,nn)) `shouldBe` "(bob, TokenTest.bob, TokenTest.bob)"
 
@@ -3789,8 +3789,8 @@
               (Just name) = locToName    (14,7) renamed
           nname <- rdrName2Name rdr
           return (rdr,name,nname)
-      ((r,n,nn),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
-      -- ((r,n,nn),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule t }) testOptions
+      ((r,n,nn),_s) <- runRefactGhc comp (initialState { rsModule = initRefactModule [] t }) testOptions
+      -- ((r,n,nn),_s) <- runRefactGhc comp (initialLogOnState { rsModule = initRefactModule [] t }) testOptions
 
       (showGhcQual (r,n,nn)) `shouldBe` "(bar, bar, bar)"
 
diff --git a/test/UtilsSpec.hs b/test/UtilsSpec.hs
--- a/test/UtilsSpec.hs
+++ b/test/UtilsSpec.hs
@@ -25,6 +25,8 @@
 import Language.Haskell.Refact.Utils.Utils
 import Language.Haskell.Refact.Utils.Variables
 
+import Language.Haskell.Refact.Refactoring.RoundTrip
+
 import System.Directory
 
 -- ---------------------------------------------------------------------
@@ -81,8 +83,19 @@
       let parsed = GHC.pm_parsed_source $ GHC.tm_parsed_module t
       (showGhc parsed) `shouldBe` "module BCpp where\nbob :: Int -> Int -> Int\nbob x y = x + y"
 
-  -- -----------------------------------
+     -- ---------------------------------
 
+    it "refactors a file having the LANGUAGE CPP pragma" $ do
+      r <- ct $ roundTrip defaultTestSettings testOptions "BCpp.hs"
+      -- r <- ct $ roundTrip logTestSettings testOptions "BCpp.hs"
+      r' <- ct $ mapM makeRelativeToCurrentDirectory r
+      r' `shouldBe` ["BCpp.hs"]
+      diff <- compareFiles "./test/testdata/BCpp.refactored.hs"
+                           "./test/testdata/BCpp.hs"
+      diff `shouldBe` []
+
+    -- ---------------------------------
+
     it "loads a series of files based on cabal1" $ do
 
       currentDir <- getCurrentDirectory
@@ -377,6 +390,22 @@
 
       setCurrentDirectory currentDir
 
+    ------------------------------------
+
+    it "gets modules for HaRe" $ do
+      {-
+      let
+        comp = do
+         parseSourceFileGhc "src/Language/Haskell/Refact/Utils/TypeUtils.hs" -- Load the file first
+         tm <- getRefactTargetModule
+         g <- clientModsAndFiles tm
+         return g
+      (mg,_s) <- runRefactGhc comp initialState testOptions
+      -- (mg,_s) <- runRefactGhc comp initialLogOnState testOptions
+      show (sort $ map GM.mpModule mg) `shouldBe` "[ModuleName \"Language.Haskell.Refact.API\",ModuleName \"Language.Haskell.Refact.HaRe\",ModuleName \"Language.Haskell.Refact.Refactoring.Case\",ModuleName \"Language.Haskell.Refact.Refactoring.DupDef\",ModuleName \"Language.Haskell.Refact.Refactoring.MoveDef\",ModuleName \"Language.Haskell.Refact.Refactoring.Renaming\",ModuleName \"Language.Haskell.Refact.Refactoring.RoundTrip\",ModuleName \"Language.Haskell.Refact.Refactoring.SwapArgs\",ModuleName \"Language.Haskell.Refact.Refactoring.Simple\",ModuleName \"MoveDefSpec\",ModuleName \"Main\",ModuleName \"Main\",ModuleName \"CaseSpec\",ModuleName \"DupDefSpec\",ModuleName \"GhcUtilsSpec\",ModuleName \"RenamingSpec\",ModuleName \"RoundTripSpec\",ModuleName \"SimpleSpec\",ModuleName \"SwapArgsSpec\",ModuleName \"TypeUtilsSpec\",ModuleName \"UtilsSpec\"]"
+    -}
+    pendingWith "make an equivalent test using testdata/cabal"
+
   -- -------------------------------------------------------------------
 
   describe "serverModsAndFiles" $ do
@@ -526,9 +555,9 @@
 
   describe "RefactFlags" $ do
     it "puts the RefactDone flag through its paces" $ do
-      t <- ct $ parsedFileGhc "./FreeAndDeclared/DeclareTypes.hs"
       let
         comp = do
+          parseSourceFileGhc "./FreeAndDeclared/DeclareTypes.hs"
           v1 <- getRefactDone
           clearRefactDone
           v2 <- getRefactDone
@@ -536,7 +565,7 @@
           v3 <- getRefactDone
 
           return (v1,v2,v3)
-      ((v1',v2',v3'), _s) <- runRefactGhc comp (initialState { rsModule = initRefactModule t }) testOptions
+      ((v1',v2',v3'), _s) <- ct $ runRefactGhc comp initialState testOptions
 
       (show (v1',v2',v3')) `shouldBe` "(False,False,True)"
 
diff --git a/test/testdata/Demote/CaseIn1.hs.expected b/test/testdata/Demote/CaseIn1.hs.expected
--- a/test/testdata/Demote/CaseIn1.hs.expected
+++ b/test/testdata/Demote/CaseIn1.hs.expected
@@ -16,4 +16,4 @@
   where
     addthree=x+y+z
 
-  
+
diff --git a/test/testdata/Demote/LetIn1.hs.expected b/test/testdata/Demote/LetIn1.hs.expected
--- a/test/testdata/Demote/LetIn1.hs.expected
+++ b/test/testdata/Demote/LetIn1.hs.expected
@@ -17,4 +17,4 @@
 anotherFun 0 y = sq y
      where  sq x = x^2
 
-  
+
diff --git a/test/testdata/Demote/WhereIn7.hs.expected b/test/testdata/Demote/WhereIn7.hs.expected
--- a/test/testdata/Demote/WhereIn7.hs.expected
+++ b/test/testdata/Demote/WhereIn7.hs.expected
@@ -17,4 +17,4 @@
 anotherFun :: Int -> Int
 
 anotherFun x = x^2
- 
+
