diff --git a/hsdev.cabal b/hsdev.cabal
--- a/hsdev.cabal
+++ b/hsdev.cabal
@@ -1,5 +1,5 @@
 name:                hsdev
-version:             0.3.3.6
+version:             0.3.3.8
 synopsis:            Haskell development library
 description:
   Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references, hayoo search etc.
@@ -159,9 +159,29 @@
   if flag(docs)
     build-depends:
       hdocs >= 0.5.3,
-      haddock-api >= 2.17.4,
       haddock-library >= 1.4.3 && < 1.9
 
+    if impl(ghc >= 8.8) && impl(ghc < 8.9)
+      build-depends:
+        haddock-api >= 2.23
+
+    if impl(ghc >= 8.6) && impl(ghc < 8.7)
+      build-depends:
+        haddock-api >= 2.21 && < 2.23
+
+    if impl(ghc >= 8.4) && impl(ghc < 8.5)
+      build-depends:
+        haddock-api == 2.20.*
+
+    if impl(ghc >= 8.2) && impl(ghc < 8.3)
+      build-depends:
+        haddock-api == 2.18.*
+
+    if impl(ghc >= 8.0) && impl(ghc < 8.2)
+      build-depends:
+        haddock-api == 2.17.*
+
+
   if flag(hlint)
     build-depends:
       hlint >= 2.0.11 && < 2.3
@@ -188,7 +208,7 @@
     ghc-boot                          >= 8.0.1 && < 8.9,
     ghc-paths                         >= 0.1.0.9 && < 0.2,
     haskell-names                     >= 0.9.1 && < 0.10.0,
-    haskell-src-exts                  >= 1.19.1 && < 1.22.0,
+    haskell-src-exts                  >= 1.19.1 && < 1.24.0,
     hformat                           >= 0.1.0.1 && < 0.4,
     hlint                             >= 2.0.11 && < 2.3,
     http-client                    >= 0.5 && < 0.7,
diff --git a/src/HsDev/Client/Commands.hs b/src/HsDev/Client/Commands.hs
--- a/src/HsDev/Client/Commands.hs
+++ b/src/HsDev/Client/Commands.hs
@@ -97,33 +97,29 @@
 	Update.scanPackageDbStack [] pdbs]
 runCommand (SetFileContents f mcts) = toValue $ serverSetFileContents f mcts
 runCommand (RefineDocs projs fs)
-	| HDocs.hdocsSupported = toValue $ do
+	| HDocs.hdocsSupported = toValue $ updateProcess def $ return $ do
 		projects <- traverse findProject projs
-		mods <- do
-			projMods <- liftM concat $ forM projects $ \proj -> do
-				ms <- loadModules "select id from modules where cabal == ? and json_extract(tags, '$.docs') is null"
-					(Only $ proj ^. projectCabal)
-				p <- SQLite.loadProject (proj ^. projectCabal)
-				return $ set (each . moduleId . moduleLocation . moduleProject) (Just p) ms
-			fileMods <- liftM concat $ forM fs $ \f ->
-				loadModules "select id from modules where file == ? and json_extract(tags, '$.docs') is null"
-					(Only f)
-			return $ projMods ++ fileMods
-		updateProcess def [Update.scanDocs mods]
-	| otherwise = hsdevError $ OtherError "docs not supported"
-runCommand (InferTypes projs fs) = toValue $ do
-	projects <- traverse findProject projs
-	mods <- do
 		projMods <- liftM concat $ forM projects $ \proj -> do
-			ms <- loadModules "select id from modules where cabal == ? and json_extract(tags, '$.types') is null"
+			ms <- loadModules "select id from modules where cabal == ? and json_extract(tags, '$.docs') is null"
 				(Only $ proj ^. projectCabal)
 			p <- SQLite.loadProject (proj ^. projectCabal)
 			return $ set (each . moduleId . moduleLocation . moduleProject) (Just p) ms
 		fileMods <- liftM concat $ forM fs $ \f ->
-			loadModules "select id from modules where file == ? and json_extract(tags, '$.types') is null"
+			loadModules "select id from modules where file == ? and json_extract(tags, '$.docs') is null"
 				(Only f)
-		return $ projMods ++ fileMods
-	updateProcess def [Update.inferModTypes mods]
+		Update.scanDocs $ projMods ++ fileMods
+	| otherwise = hsdevError $ OtherError "docs not supported"
+runCommand (InferTypes projs fs) = toValue $ updateProcess def $ return $ do
+	projects <- traverse findProject projs
+	projMods <- liftM concat $ forM projects $ \proj -> do
+		ms <- loadModules "select id from modules where cabal == ? and json_extract(tags, '$.types') is null"
+			(Only $ proj ^. projectCabal)
+		p <- SQLite.loadProject (proj ^. projectCabal)
+		return $ set (each . moduleId . moduleLocation . moduleProject) (Just p) ms
+	fileMods <- liftM concat $ forM fs $ \f ->
+		loadModules "select id from modules where file == ? and json_extract(tags, '$.types') is null"
+			(Only f)
+	Update.inferModTypes $ projMods ++ fileMods
 runCommand (Remove projs cabal sboxes files) = toValue $ withSqlConnection $ SQLite.transaction_ SQLite.Immediate $ do
 	let
 		-- We can safely remove package-db from db iff doesn't used by some of other package-dbs
diff --git a/src/HsDev/Tools/Ghc/Compat.hs b/src/HsDev/Tools/Ghc/Compat.hs
--- a/src/HsDev/Tools/Ghc/Compat.hs
+++ b/src/HsDev/Tools/Ghc/Compat.hs
@@ -29,9 +29,14 @@
 import qualified Packages as GHC
 import qualified PatSyn as GHC
 import qualified Pretty
-import qualified SysTools
 import Outputable
 
+#if __GLASGOW_HASKELL__ >= 804
+import FileCleanup (cleanTempDirs, cleanTempFiles)
+#else
+import SysTools (cleanTempDirs, cleanTempFiles)
+#endif
+
 #if __GLASGOW_HASKELL__ >= 800
 import Data.List (nub)
 import qualified IdInfo
@@ -241,13 +246,9 @@
 #endif
 
 cleanTemps :: GHC.DynFlags -> IO ()
-#if __GLASGOW_HASKELL__ >= 804
-cleanTemps _ = return ()
-#else
 cleanTemps df = do
-	SysTools.cleanTempFiles df
-	SysTools.cleanTempDirs df
-#endif
+	cleanTempFiles df
+	cleanTempDirs df
 
 mgArgTys :: GHC.MatchGroup TcId (GHC.LHsExpr TcId) -> Maybe [GHC.Type]
 #if __GLASGOW_HASKELL__ >= 806
diff --git a/src/HsDev/Tools/Ghc/Worker.hs b/src/HsDev/Tools/Ghc/Worker.hs
--- a/src/HsDev/Tools/Ghc/Worker.hs
+++ b/src/HsDev/Tools/Ghc/Worker.hs
@@ -30,6 +30,7 @@
 import Exception (ExceptionMonad(..), ghandle)
 import GHC hiding (Warning, Module)
 import GHC.Paths
+import Linker (initDynLinker)
 
 import Control.Concurrent.Worker
 import HsDev.PackageDb.Types
@@ -93,6 +94,7 @@
 	Log.sendLog Log.Trace $ "session: {}" ~~ SessionConfig ty pdbs
 	switchSession_ (SessionConfig ty pdbs) $ Just initialize
 	setSessionFlags
+	Log.sendLog Log.Trace "session set"
 	where
 		toKill (SessionConfig ty' pdbs') = or [
 			(ty == ty' && pdbs /= pdbs'),
@@ -103,8 +105,8 @@
 			setSessionData (First $ Just dflags)
 		run = case ty of
 			SessionGhci -> ghcRun pdbsOpts (importModules preludeModules)
-			SessionGhc -> ghcRun pdbsOpts (return ())
-			SessionTmp -> ghcRun pdbsOpts (return ())
+			SessionGhc -> ghcRun pdbsOpts (getSession >>= liftIO . initDynLinker)
+			SessionTmp -> ghcRun pdbsOpts (getSession >>= liftIO . initDynLinker)
 			SessionHaddock -> ghcRunWith noLinkFlags ("-haddock" : pdbsOpts) (return ())
 		setSessionFlags = do
 			Log.sendLog Log.Trace $ "setting flags: {}" ~~ unwords opts
