diff --git a/Readme.md b/Readme.md
--- a/Readme.md
+++ b/Readme.md
@@ -2,34 +2,118 @@
 
 [![Build Status](https://secure.travis-ci.org/leksah/leksah.png?branch=vcs)](http://travis-ci.org/leksah/leksah)
 
-This is [Leksah](http://leksah.org/), a hopefully practical tool to support the Haskell development process.
-
-Leksah uses GTK+ as GUI Toolkit with the gtk2hs binding. It is plattform independent
-and should run on any plattform where GTK+, gtk2hs and ghc can be installed.
-It has currently been tested on Linux, Mac OS X and Windows. It uses the Cabal package management
-and build system for Package Management. It currently only supports the Glasgow Haskell Compiler (ghc).
+[Leksah](http://leksah.org/) aims to integrate various Haskell development
+tools to provide a practical and plesant development environment.
+The user interface is a mix of GTK+ and WebKit based components.
 
 Documentation can be found on [leksah.org](http://leksah.org/).
 
-## System Requirements
+## Installation
 
-Leksah currently requires:
+You can get Leksah up and running quickly on Windows and OS X using the
+[official binaries](https://github.com/leksah/leksah/wiki/download).
 
-* GHC
-* gtk2hs
-* For more details see the leksah.cabal file
+Some Linux distributions include Leksah packages, but building from source
+on Linux is normally relatively easy.
 
-To build the latest development version of Leksah follow the
-steps in the [.travis.yml](.travis.yml) file.
+## Building From Source
 
-If you are a user and would simply like to test Leksah, we would highly appreciate your feedback.
+### Building on Linux
 
-Please send questions and suggestions to
-the [Leksah group](https://groups.google.com/forum/#!forum/leksah)
+Install the GtkSourceView and WebKitGtk development packages for your distribution:
 
-Thank you!
+    sudo apt-get install libgtksourceview-3.0-dev libwebkitgtk-3.0-dev
 
+Make sure `$HOME/.cabal/bin` is in your `PATH` then:
+    
+	cabal update
+	cabal install Cabal cabal-install
+    cabal install alex happy 
+    cabal install gtk2hs-buildtools
+    cabal install leksah
+    leksah
 
+### Buildling on OS X
 
+[Install MacPorts](https://www.macports.org/install.php).
 
+Make sure `/opt/local/bin` and `$HOME/Libraries/Haskell/bin` are in your `PATH`.
 
+To avoid a dependency on X11 add the following to `/opt/local/etc/macports/variants.conf`:
+
+    -x11 +no_x11 +quartz +gtk3
+
+Use MacPorts to install `python27` and `rsync` (sometimes it stops to ask for these to be
+activated so if you do them first it might help):
+
+    sudo port install python27 rsync
+
+Use MacPorts to install GHC and the C libraries needed by Leksah (this will take a long time):
+     
+    sudo port install ghc gtk3 webkit-gtk3 gtksourceview3 gtk-osx-application adwaita-icon-theme
+
+Update Cabal and cabal-install
+
+	cabal update
+	cabal install Cabal cabal-install
+
+Make sure the right `cabal` made it into your `PATH`.
+
+    cabal --version
+
+Check that the versions match the ones you just installed (if not check the symbolic links in
+`$HOME/Libraries/Haskell/bin`).
+
+Install `gtk2hs-buildtools` and `leksah`:
+
+    cabal install alex happy 
+    cabal install gtk2hs-buildtools
+    cabal install leksah
+    leksah
+
+### Building on Windows
+
+Install [GHC](https://www.haskell.org/downloads/windows).
+
+Update MinGW if necessary.  The GHC installers currently come with old versions of
+MinGW and you will probably need to replace it with one that comes with gcc 4.8.1.
+The current 64bit GHC installer seems to be happy to work with newer MinGW.
+It may not be possible to use the current 32bit GHC installers at all.
+Make sure you replace MinGW so that GHC will find the new one (just adding
+it to the `PATH` will not work). The MinGW used by GHC is typically in a location
+like `C:\Program Files\MinGHC-7.10.1\ghc-7.10.1\mingw`.  Move it out of the way
+and put a newer one in its place.
+
+[MinGW version used to build the Leksah binaries](http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-posix/seh/x86_64-4.9.2-release-posix-seh-rt_v4-rev2.7z)
+
+Install the C libraries needed by Leksah.  The easiest way to do this is to install
+Leksah using the MSI files.  They include pkg-config and all the C libraries needed.
+
+Make sure `C:\Leksah\bin` and `%APPDATA%\cabal\bin` are in your `PATH` and build:
+
+	cabal update
+	cabal install Cabal
+    cabal install alex happy 
+    cabal install gtk2hs-buildtools
+    cabal install leksah
+    leksah
+   
+### Building Leksah for Windows using Docker
+
+It may seem crazy, but this is currently the best way to bootstrap Leksah for
+Windows from source.  This is mostly because Fedora and SUSE have a much
+more complete set of MinGW packages than any thing else (including Windows).
+
+Get the leksah source:
+
+    git clone https://github.org/leksah/leksah
+    cd leksah
+    git submodule update --init
+
+Build it using the Dockerfile:
+
+    sudo docker build -t leksah/build .
+
+Copy the resulting msi file out of the container (version number in the file name will match the one in the leksah.cabal file):
+
+    sudo docker run --rm --volume $HOME/output:/output leksah/build cp /leksah/win32/leksah-0.15.0.1-ghc-7.10.1.msi /output
diff --git a/data/prefs.lkshp b/data/prefs.lkshp
--- a/data/prefs.lkshp
+++ b/data/prefs.lkshp
@@ -46,7 +46,7 @@
 Paths under which haskell sources for packages may be found:
                []
 Unpack source for cabal packages to:
-               Just "~/.leksah-0.14/packageSources"
+               Just "~/.leksah-0.15/packageSources"
 URL from which to download prebuilt metadata:
                "http://www.leksah.org"
 Strategy for downloading prebuilt metadata:
@@ -60,7 +60,7 @@
 Stop the leksah-server process when leksah disconnects:
                True
 Packages which are excluded from the modules pane:
-               [Dependency (PackageName "ghc") AnyVersion]
+               ["ghc -any"]
 Automatically save all files before building:
                True
 Background build:
diff --git a/data/prefscoll.lkshp b/data/prefscoll.lkshp
--- a/data/prefscoll.lkshp
+++ b/data/prefscoll.lkshp
@@ -1,7 +1,7 @@
 Paths under which haskell sources for packages may be found:
                []
 Unpack source for cabal packages to:
-               Just "~/.leksah-0.14/packageSources"
+               Just "~/.leksah-0.15/packageSources"
 URL from which to download prebuilt metadata:
                "http://www.leksah.org"
 Strategy for downloading prebuilt metadata:
diff --git a/data/styles/leksah-dark.xml b/data/styles/leksah-dark.xml
--- a/data/styles/leksah-dark.xml
+++ b/data/styles/leksah-dark.xml
@@ -75,7 +75,7 @@
   <style name="def:error"                   background="red" bold="true"/>
   <style name="def:warning"                 background="yellow"/>
   <style name="def:note"                    foreground="comment" background="yellow" bold="true"/>
-  <style name="def:underlined"              italic="true" underline="true"/>
+  <style name="def:underlined"              italic="true" underline="false"/>
 
   <!-- Language specific styles -->
   <style name="diff:added-line"             foreground="#008B8B"/>
diff --git a/data/styles/leksah.xml b/data/styles/leksah.xml
--- a/data/styles/leksah.xml
+++ b/data/styles/leksah.xml
@@ -75,7 +75,7 @@
   <style name="def:error"                   background="red" bold="true"/>
   <style name="def:warning"                 background="yellow"/>
   <style name="def:note"                    foreground="comment" background="yellow" bold="true"/>
-  <style name="def:underlined"              italic="true" underline="true"/>
+  <style name="def:underlined"              italic="true" underline="false"/>
 
   <!-- Language specific styles -->
   <style name="diff:added-line"             foreground="#008B8B"/>
diff --git a/language-specs/cabal.lang b/language-specs/cabal.lang
--- a/language-specs/cabal.lang
+++ b/language-specs/cabal.lang
@@ -53,6 +53,7 @@
       <keyword>build-type</keyword>
       <keyword>license</keyword>
       <keyword>license-file</keyword>
+      <keyword>license-files</keyword>
       <keyword>copyright</keyword>
       <keyword>maintainer</keyword>
       <keyword>build-depends</keyword>
@@ -95,6 +96,7 @@
         <context ref="lib"/>
         <context ref="exe"/>
         <context ref="test"/>
+        <context ref="benchmark"/>
         <context ref="custom"/>
       </include>
     </context>
@@ -119,6 +121,7 @@
         <context ref="lib"/>
         <context ref="exe"/>
         <context ref="test"/>
+        <context ref="benchmark"/>
         <context ref="custom"/>
       </include>
     </context>
@@ -168,6 +171,7 @@
         <context ref="flag"/>
         <context ref="exe"/>
         <context ref="test"/>
+        <context ref="benchmark"/>
         <context ref="conditional"/>
         <context ref="custom"/>
       </include>
@@ -219,6 +223,7 @@
         <context ref="lib"/>
         <context ref="exe"/>
         <context ref="test"/>
+        <context ref="benchmark"/>
         <context ref="conditional"/>
         <context ref="custom"/>
       </include>
@@ -271,11 +276,64 @@
         <context ref="lib"/>
         <context ref="exe"/>
         <context ref="test"/>
+        <context ref="benchmark"/>
         <context ref="conditional"/>
         <context ref="custom"/>
       </include>
     </context>
 
+    <context id="benchmark-field-name" style-ref="field-name">
+      <prefix>^ +</prefix>
+      <suffix>:</suffix>
+      <keyword>build-depends</keyword>
+      <!-- putStrLn $ concatMap (\f -> "      <keyword>" ++ fieldName f ++ "</keyword>\n") testSuiteFieldDescrs -->
+      <keyword>type</keyword>
+      <keyword>main-is</keyword>
+      <keyword>buildable</keyword>
+      <keyword>build-tools</keyword>
+      <keyword>cpp-options</keyword>
+      <keyword>cc-options</keyword>
+      <keyword>ld-options</keyword>
+      <keyword>pkgconfig-depends</keyword>
+      <keyword>frameworks</keyword>
+      <keyword>c-sources</keyword>
+      <keyword>default-language</keyword>
+      <keyword>other-languages</keyword>
+      <keyword>default-extensions</keyword>
+      <keyword>other-extensions</keyword>
+      <keyword>extensions</keyword>
+      <keyword>extra-libraries</keyword>
+      <keyword>extra-lib-dirs</keyword>
+      <keyword>includes</keyword>
+      <keyword>install-includes</keyword>
+      <keyword>include-dirs</keyword>
+      <keyword>hs-source-dirs</keyword>
+      <keyword>other-modules</keyword>
+      <keyword>ghc-prof-options</keyword>
+      <keyword>ghc-shared-options</keyword>
+      <keyword>ghc-options</keyword>
+      <keyword>hugs-options</keyword>
+      <keyword>nhc98-options</keyword>
+      <keyword>jhc-options</keyword>
+    </context>
+
+    <context id="benchmark" end-parent="true">
+      <start>^(benchmark) </start>
+      <include>
+        <context sub-pattern="1" where="start" style-ref="keyword"/>
+        <context ref="line-comment"/>
+        <context ref="benchmark-field-name"/>
+        <context ref="source-repo"/>
+        <context ref="flag"/>
+        <context ref="lib"/>
+        <context ref="exe"/>
+        <context ref="test"/>
+        <context ref="benchmark"/>
+        <context ref="conditional"/>
+        <context ref="custom"/>
+      </include>
+    </context>
+
     <context id="line-comment" style-ref="comment" end-at-line-end="true">
       <start>--</start>
       <include>
@@ -292,6 +350,7 @@
         <context ref="lib"/>
         <context ref="exe"/>
         <context ref="test"/>
+        <context ref="benchmark"/>
         <context ref="custom"/>
       </include>
     </context>
diff --git a/leksah.cabal b/leksah.cabal
--- a/leksah.cabal
+++ b/leksah.cabal
@@ -1,5 +1,5 @@
 name: leksah
-version: 0.14.4.0
+version: 0.15.0.1
 cabal-version: >=1.18
 build-type: Simple
 license: GPL
@@ -221,9 +221,6 @@
         build-depends: dyre >= 0.8.3 && <0.9
         cpp-options: -DLEKSAH_WITH_YI_DYRE
 
-    if flag(threaded)
-        ghc-options: -threaded
-
     if flag(gtk3)
       build-depends: gtk3 >=0.13.2 && <0.14, gtksourceview3 >=0.13.1.0 && <0.14
       cpp-options:   -DMIN_VERSION_gtk=MIN_VERSION_gtk3
@@ -250,19 +247,19 @@
     hs-source-dirs: src
     default-language: Haskell98
 
-    build-depends: Cabal >=1.10.2.0 && <1.22, base >=4.0.0.0 && <4.8, binary >=0.5.0.0 && <0.8,
+    build-depends: Cabal >=1.10.2.0 && <1.23, base >=4.0.0.0 && <4.9, binary >=0.5.0.0 && <0.8,
                        bytestring >=0.9.0.1 && <0.11, containers >=0.2.0.0 && <0.6, directory >=1.0.0.2 && <3.1,
-                       filepath >=1.1.0.1 && <1.4, glib >=0.13.0.0 && <0.14,
+                       filepath >=1.1.0.1 && <1.5, glib >=0.13.0.0 && <0.14,
                        mtl >=1.1.0.2 && <2.3, old-time >=1.0.0.1 && <1.2,
                        parsec >=2.1.0.1 && <3.2, pretty >=1.0.1.0 && <1.2,
-                       regex-tdfa >=1.1 && <1.3, regex-tdfa-text, regex-base ==0.93.*, utf8-string >=0.3.1.1 && <0.4, array >=0.2.0.0 && <0.6,
-                       time >=0.1 && <1.5, ltk >= 0.14.3.0 && <0.15, binary-shared >= 0.8 && <0.9, deepseq >= 1.1.0.0 && <1.4,
-                       hslogger >= 1.0.7 && <1.3, leksah-server >=0.14.3.1 && <0.15,
-                       ghc >=6.10.1 && <7.9, strict >= 0.3.2 && <0.4, conduit >= 1.0.8 && <1.3, text >= 0.11.1.5 && < 1.3,
+                       regex-tdfa >=1.1 && <1.3, regex-tdfa-text, regex-base ==0.93.*, utf8-string >=0.3.1.1 && <1.1, array >=0.2.0.0 && <0.6,
+                       time >=0.1 && <1.6, ltk >= 0.15.0.1 && <0.16, binary-shared >= 0.8 && <0.9, deepseq >= 1.1.0.0 && <1.5,
+                       hslogger >= 1.0.7 && <1.3, leksah-server >=0.15.0.1 && <0.16,
+                       ghc >=6.10.1 && <7.11, strict >= 0.3.2 && <0.4, conduit >= 1.0.8 && <1.3, text >= 0.11.1.5 && < 1.3,
                        gio >=0.13.0.0 && <0.14, transformers >=0.2.2.0 && <0.5,
                        executable-path >=0.0.3 && <0.1,
                        vcsgui >=0.1.0 && < 0.2, vcswrapper >=0.1.0 && < 0.2,
-                       QuickCheck >=2.4.2 && <2.8, haskell-src-exts >=1.13.5 && <1.17,
+                       QuickCheck >=2.4.2 && <2.9, haskell-src-exts >=1.13.5 && <1.17,
                        hlint >=1.8.59 && <1.10, vado >=0.0.1 && <0.1, shakespeare >=2.0.0.1 && <2.1
     exposed-modules: IDE.Leksah IDE.Completion IDE.ImportTool IDE.Find
                      IDE.Sandbox IDE.Session IDE.Command IDE.Keymap IDE.Utils.GUIUtils
@@ -290,10 +287,7 @@
         build-depends: binary-shared >=0.8.2
 
     other-modules: Paths_leksah
-
-    ghc-prof-options: -auto-all -prof
-    ghc-shared-options: -auto-all
-    ghc-options: -O2 -fwarn-missing-fields -fwarn-incomplete-patterns -ferror-spans
+    ghc-options: -fwarn-missing-fields -fwarn-incomplete-patterns -ferror-spans
 
 Executable leksah
     if os(windows)
@@ -310,7 +304,11 @@
         ghc-options: -threaded
 
     hs-source-dirs: main
-    build-depends: leksah == 0.14.4.0, base >= 4.0.0.0 && <=4.8, gtk3 -any
+    build-depends: leksah == 0.15.0.1, base >= 4.0.0.0 && <=4.9
+    if flag(gtk3)
+        build-depends: gtk3 >=0.13.2 && <0.14
+    else
+        build-depends: gtk >=0.13.2 && <0.14
     if os(linux) && flag(loc)
         cpp-options: -DLOCALIZATION
         build-depends: hgettext, setlocale
@@ -321,12 +319,10 @@
     default-language: Haskell98
     main-is: Main.hs
     buildable: True
-    ghc-prof-options: -auto-all -prof
-    ghc-shared-options: -auto-all
-    ghc-options: -rtsopts -O2 -fwarn-missing-fields -fwarn-incomplete-patterns -ferror-spans
+    ghc-options: -rtsopts -fwarn-missing-fields -fwarn-incomplete-patterns -ferror-spans
 
 executable bewleksah
-    build-depends: leksah ==0.14.4.0, base >=4.0.0.0 && <=4.8,
+    build-depends: leksah ==0.15.0.1, base >=4.0.0.0 && <=4.9,
                    jsaddle -any, ghcjs-dom -any
     if flag(gtk3)
       build-depends: gtk3 >=0.13.2 && <0.14, gtksourceview3 >=0.13.1.0 && <0.14,
@@ -342,8 +338,8 @@
     hs-source-dirs: bew
 
 test-suite tests
-    build-depends: base >=4.0.0.0 && <4.8, Cabal >=1.10.2.0 && <1.22,
-                   QuickCheck >=2.4.2 && <2.8, leksah ==0.14.4.0,
+    build-depends: base >=4.0.0.0 && <4.9, Cabal >=1.10.2.0 && <1.23,
+                   QuickCheck >=2.4.2 && <2.9, leksah ==0.15.0.1,
                    containers, ltk, leksah-server, hslogger,
                    transformers, glib, monad-loops, text
     if flag(gtk3)
diff --git a/osx/Info.plist b/osx/Info.plist
--- a/osx/Info.plist
+++ b/osx/Info.plist
@@ -7,7 +7,7 @@
     <key>CFBundleExecutable</key>
     <string>Leksah</string>
     <key>CFBundleGetInfoString</key>
-    <string>0.14.0.0</string>
+    <string>0.15.0.0</string>
     <key>CFBundleIconFile</key>
     <string>leksah.icns</string>
     <key>CFBundleIdentifier</key>
@@ -17,11 +17,11 @@
     <key>CFBundlePackageType</key>
     <string>APPL</string>
     <key>CFBundleShortVersionString</key>
-    <string>0.14.0.0</string>
+    <string>0.15.0.0</string>
     <key>CFBundleSignature</key>
     <string>????</string>
     <key>CFBundleVersion</key>
-    <string>0.14.0.0</string>
+    <string>0.15.0.0</string>
     <key>NSHumanReadableCopyright</key>
     <string>2007-2011 Jürgen Nicklisch-Franken, GNU General Public License.</string>
     <key>LSMinimumSystemVersion</key>
diff --git a/osx/leksah.bundle b/osx/leksah.bundle
--- a/osx/leksah.bundle
+++ b/osx/leksah.bundle
@@ -60,6 +60,7 @@
   <main-binary>${prefix:leksah-bin}/bin/leksah</main-binary>
 
   <binary>${prefix:leksah-server-bin}/bin/leksahecho</binary>
+  <binary>${prefix:leksah-server-bin}/bin/leksahtrue</binary>
   <binary>${prefix:leksah-server-bin}/bin/leksah-server</binary>
   <binary>${prefix:vcsgui-bin}/bin/vcsgui</binary>
   <binary>${prefix:vcsgui-bin}/bin/vcsgui-askpass</binary>
diff --git a/scripts/stage.sh b/scripts/stage.sh
--- a/scripts/stage.sh
+++ b/scripts/stage.sh
@@ -1,18 +1,18 @@
 #!/bin/sh
 
-ghc-pkg$GHCVERSION unregister leksah || true
-ghc-pkg$GHCVERSION unregister leksah-server || true
-ghc-pkg$GHCVERSION unregister ltk || true
+$WINE ghc-pkg$GHCVERSION unregister leksah || true
+$WINE ghc-pkg$GHCVERSION unregister leksah-server || true
+$WINE ghc-pkg$GHCVERSION unregister ltk || true
 
 export FULL_VERSION=`grep '^version: ' leksah.cabal | sed 's|version: ||' | tr -d '\r'`
 export SHORT_VERSION=`echo $FULL_VERSION | sed 's|\.[0-9]*\.[0-9]*$||'`
 export LEKSAH_X_X_X_X=leksah-$FULL_VERSION
 export LEKSAH_X_X=leksah-$SHORT_VERSION
 
-export GHC_VER=`ghc$GHCVERSION --numeric-version`
+export GHC_VER=`$WINE ghc$GHCVERSION --numeric-version | tr -d '\r'`
 export LEKSAH_X_X_X_X_GHC_X_X_X=leksah-$FULL_VERSION-ghc-$GHC_VER
 
-export GTK_PREFIX=`pkg-config --libs-only-L gtk+-3.0 | sed 's|^-L||' | sed 's|/lib *.*$||'`
+export GTK_PREFIX=`$WINE pkg-config --libs-only-L gtk+-3.0 | sed 's|^-L||' | sed 's|/lib *.*$||'`
 
 echo Staging Leksah in $GTK_PREFIX
 
@@ -36,11 +36,11 @@
     cabal install --enable-tests -j4 --with-ghc=ghc$GHCVERSION || exit
     cabal test || exit
     cd ../yi || exit
-    cabal install -j4 -fpango --with-ghc=ghc$GHCVERSION || exit
+#    cabal install -j4 -fpango --with-ghc=ghc$GHCVERSION || exit
     cd ../.. || exit
-    cabal install -j4 -fwebkit -fyi --with-gcc=gcc-mp-4.8 --with-ghc=ghc$GHCVERSION || exit
+    cabal install -j4 -fwebkit -f-yi --with-ghc=ghc$GHCVERSION || exit
 else
-    cabal install ./ ./vendor/ltk ./vendor/leksah-server                gtk3 ghcjs-dom jsaddle vendor/haskellVCSWrapper/vcswrapper vendor/haskellVCSGUI/vcsgui --with-ghc=ghc$GHCVERSION -j4 -fwebkit -f-yi -fpango -f-vty --force-reinstalls --extra-lib-dirs=/c/MinGWRPM/lib || bash || exit
+    $WINE cabal install ./ ./vendor/ltk ./vendor/leksah-server                gtk3 ghcjs-dom jsaddle vendor/haskellVCSWrapper/vcswrapper vendor/haskellVCSGUI/vcsgui --with-ghc=ghc$GHCVERSION -j4 -fwebkit -f-yi -fpango -f-vty --force-reinstalls || exit
 #  if [ "$GHC_VER" != "7.0.3" ] && [ "$GHC_VER" != "7.0.4" ] && [ "$GHC_VER" != "7.6.1" ]; then
 #    echo https://github.com/yi-editor/yi.git >> sources.txt
 #    export LEKSAH_CONFIG_ARGS="$LEKSAH_CONFIG_ARGS -fyi -f-vty -f-dyre -fpango"
diff --git a/src/IDE/BufferMode.hs b/src/IDE/BufferMode.hs
--- a/src/IDE/BufferMode.hs
+++ b/src/IDE/BufferMode.hs
@@ -155,10 +155,10 @@
     modeEditUncomment      :: IDEAction,
     modeSelectedModuleName :: IDEM (Maybe Text),
     modeEditToCandy        :: (Text -> Bool) -> IDEAction,
-    modeTransformToCandy   :: TextEditor editor => (Text -> Bool) -> EditorBuffer editor -> IDEAction,
+    modeTransformToCandy   :: forall editor . TextEditor editor => (Text -> Bool) -> EditorBuffer editor -> IDEAction,
     modeEditFromCandy      :: IDEAction,
     modeEditKeystrokeCandy :: Maybe Char -> (Text -> Bool) -> IDEAction,
-    modeEditInsertCode     :: TextEditor editor => Text -> EditorIter editor -> EditorBuffer editor -> IDEAction,
+    modeEditInsertCode     :: forall editor . TextEditor editor => Text -> EditorIter editor -> EditorBuffer editor -> IDEAction,
     modeEditInCommentOrString :: Text -> Bool
     }
 
diff --git a/src/IDE/Build.hs b/src/IDE/Build.hs
--- a/src/IDE/Build.hs
+++ b/src/IDE/Build.hs
@@ -80,6 +80,7 @@
 data MakeOp =
     MoConfigure
     | MoBuild
+    | MoTest
     | MoCopy
     | MoRegister
     | MoClean
@@ -200,10 +201,12 @@
 doBuildChain ms chain@Chain{mcAction = MoConfigure} =
     packageConfig' (mcEle chain) (constrCont ms (mcPos chain) (mcNeg chain))
 doBuildChain ms chain@Chain{mcAction = MoBuild} =
-    buildPackage (msBackgroundBuild ms) (msRunUnitTests ms) (msJumpToWarnings ms) (not (msMakeMode ms) && msSingleBuildWithoutLinking ms)
+    buildPackage (msBackgroundBuild ms) (msJumpToWarnings ms) (not (msMakeMode ms) && msSingleBuildWithoutLinking ms)
         (mcEle chain) (constrCont ms (mcPos chain) (mcNeg chain))
 doBuildChain ms chain@Chain{mcAction = MoDocu} =
     packageDoc' (msBackgroundBuild ms) (msJumpToWarnings ms) (mcEle chain) (constrCont ms (mcPos chain) (mcNeg chain))
+doBuildChain ms chain@Chain{mcAction = MoTest} =
+    packageTest' (mcEle chain) False (constrCont ms (mcPos chain) (mcNeg chain))
 doBuildChain ms chain@Chain{mcAction = MoCopy} =
     packageCopy' (mcEle chain) (constrCont ms (mcPos chain) (mcNeg chain))
 doBuildChain ms chain@Chain{mcAction = MoRegister} =
diff --git a/src/IDE/Core/State.hs b/src/IDE/Core/State.hs
--- a/src/IDE/Core/State.hs
+++ b/src/IDE/Core/State.hs
@@ -312,7 +312,7 @@
 liftYi :: Yi.YiM a -> IDEM a
 liftYi = liftYiControl . Yi.liftYi
 
-catchIDE :: Exception e	=> IDEM a -> (e -> IO a) -> IDEM a
+catchIDE :: Exception e => IDEM a -> (e -> IO a) -> IDEM a
 catchIDE block handler = reifyIDE (\ideR -> catch (reflectIDE block ideR) handler)
 
 forkIDE :: IDEAction  -> IDEAction
diff --git a/src/IDE/Core/Types.hs b/src/IDE/Core/Types.hs
--- a/src/IDE/Core/Types.hs
+++ b/src/IDE/Core/Types.hs
@@ -101,6 +101,7 @@
 import Data.Map (Map(..))
 import Data.Set (Set(..))
 import Data.List (nubBy)
+import Control.Concurrent (MVar)
 import Distribution.ModuleName (ModuleName(..))
 import Graphics.UI.Gtk.Gdk.EventM (Modifier(..))
 import Graphics.UI.Gtk.ActionMenuToolbar.UIManager(MergeId)
@@ -169,6 +170,7 @@
 ,   debugState      ::   Maybe (IDEPackage, ToolState)
 ,   completion      ::   ((Int, Int), Maybe CompletionWindow)
 ,   yiControl       ::   Yi.Control
+,   serverQueue     ::   Maybe (MVar (ServerCommand, (ServerAnswer -> IDEM ())))
 ,   server          ::   Maybe Handle
 ,   vcsData         ::   (Map FilePath MenuItem, Maybe (Maybe Text)) -- menus for packages, password
 ,   logLaunches     ::   Map.Map Text LogLaunchData
diff --git a/src/IDE/Leksah.hs b/src/IDE/Leksah.hs
--- a/src/IDE/Leksah.hs
+++ b/src/IDE/Leksah.hs
@@ -81,6 +81,10 @@
 import qualified Data.Text as T (pack, unpack, stripPrefix)
 import Data.Text (Text)
 import Data.Monoid ((<>))
+import Graphics.UI.Gtk.General.CssProvider
+       (cssProviderLoadFromString, cssProviderNew)
+import Graphics.UI.Gtk.General.StyleContext
+       (styleContextAddProviderForScreen)
 
 -- --------------------------------------------------------------------
 -- Command line options
@@ -214,7 +218,18 @@
     st          <-  unsafeInitGUIForThreadedRTS
     when rtsSupportsBoundThreads
         (sysMessage Normal "Linked with -threaded")
-    timeout <- timeoutAddFull (yield >> return True) priorityHigh 10
+    timeout <- timeoutAddFull (yield >> return True) priorityLow 10
+    mbScreen <- screenGetDefault
+    case mbScreen of
+        Just screen -> do
+            provider <- cssProviderNew
+            cssProviderLoadFromString provider (
+                ".window-frame,\n" <>
+                ".window-frame:backdrop {\n" <>
+                "  box-shadow: none;\n" <>
+                "  margin: 0;}\n" :: Text)
+            styleContextAddProviderForScreen screen provider 600
+        Nothing -> debugM "leksah" "Unable to add style provider for screen"
     mapM_ (sysMessage Normal . T.pack) st
     initGtkRc
     dataDir       <- getDataDir
@@ -288,7 +303,7 @@
     loop isIdle delay n = do
         quit <- if n > 0
                     then do
-                        timeout <- timeoutAddFull (yield >> return True) priorityHigh 10
+                        timeout <- timeoutAddFull (yield >> return True) priorityLow 10
                         quit <- loopn (n+2)
                         timeoutRemove timeout
                         return quit
@@ -319,7 +334,7 @@
 startMainWindow :: Yi.Control -> FilePath -> Maybe FilePath -> [FilePath] ->
                         Prefs -> Bool -> IO ()
 startMainWindow yiControl sessionFP mbWorkspaceFP sourceFPs startupPrefs isFirstStart = do
-    timeout <- timeoutAddFull (yield >> return True) priorityHigh 10
+    timeout <- timeoutAddFull (yield >> return True) priorityLow 10
     debugM "leksah" "startMainWindow"
     osxApp <- OSX.applicationNew
     uiManager   <-  uiManagerNew
@@ -376,6 +391,7 @@
           ,   debugState        =   Nothing
           ,   completion        =   ((750,400),Nothing)
           ,   yiControl         =   yiControl
+          ,   serverQueue       =   Nothing
           ,   server            =   Nothing
           ,   vcsData           =   (Map.empty, Nothing)
           ,   logLaunches       =   Map.empty
diff --git a/src/IDE/LogRef.hs b/src/IDE/LogRef.hs
--- a/src/IDE/LogRef.hs
+++ b/src/IDE/LogRef.hs
@@ -70,7 +70,7 @@
 import Data.Text (Text)
 import Control.Applicative ((<$>))
 import qualified Data.Text as T
-       (stripPrefix, isPrefixOf, unpack, unlines, pack, null)
+       (length, stripPrefix, isPrefixOf, unpack, unlines, pack, null)
 import Data.Monoid ((<>))
 
 showSourceSpan :: LogRef -> Text
@@ -306,8 +306,25 @@
         char ':'
         col <- int
         return $ SrcSpan filePath line (fixColumn col) line (fixColumn col))
-    <?> "srcLocParser"
+    <?> "srcSpanParser"
 
+docTestParser :: CharParser () (SrcSpan, Text)
+docTestParser = try (do
+        symbol "###"
+        whiteSpace
+        symbol "Failure"
+        whiteSpace
+        symbol "in"
+        whiteSpace
+        file <- many (noneOf ":")
+        char ':'
+        line <- int
+        char ':'
+        whiteSpace
+        text <- T.pack <$> many anyChar
+        return ((SrcSpan file line 7 line (T.length text - 7)), "Failure in " <> text))
+    <?> "docTestParser"
+
 data BuildError =   BuildLine
                 |   EmptyLine
                 |   ErrorLine SrcSpan LogRefType Text
@@ -470,9 +487,10 @@
                   -> Bool
                   -> C.Sink ToolOutput IDEM [LogRef]
 logOutputForBuild package backgroundBuild jumpToWarnings = do
+    liftIO $ putStrLn $ "logOutputForBuild"
     log    <- lift getLog
     logLaunch <- lift $ Log.getDefaultLogLaunch
-    (_, _, errs) <- CL.foldM (readAndShow logLaunch) (log, False, [])
+    (_, _, _, errs) <- CL.foldM (readAndShow logLaunch) (log, False, False, [])
     ideR <- lift ask
     liftIO $ postGUISync $ reflectIDE (do
         setErrorList $ reverse errs
@@ -484,8 +502,8 @@
         unless (backgroundBuild || (not jumpToWarnings && errorNum == 0)) nextError
         return errs) ideR
   where
-    readAndShow :: LogLaunch -> (IDELog, Bool, [LogRef]) -> ToolOutput -> IDEM (IDELog, Bool, [LogRef])
-    readAndShow logLaunch (log, inError, errs) output = do
+    readAndShow :: LogLaunch -> (IDELog, Bool, Bool, [LogRef]) -> ToolOutput -> IDEM (IDELog, Bool, Bool, [LogRef])
+    readAndShow logLaunch (log, inError, inDocTest, errs) output = do
         ideR <- ask
         liftIO $ postGUISync $ case output of
             ToolError line -> do
@@ -506,34 +524,48 @@
                 case (parsed, errs) of
                     (Left e,_) -> do
                         sysMessage Normal . T.pack $ show e
-                        return (log, False, errs)
+                        return (log, False, False, errs)
                     (Right ne@(ErrorLine span refType str),_) ->
-                        return (log, True, ((LogRef span package str (lineNr,lineNr) refType):errs))
+                        return (log, True, False, ((LogRef span package str (lineNr,lineNr) refType):errs))
                     (Right (OtherLine str1),(LogRef span rootPath str (l1,l2) refType):tl) ->
                         if inError
-                            then return (log, True, ((LogRef span
+                            then return (log, True, False, ((LogRef span
                                                     rootPath
                                                     (if T.null str
                                                         then line
                                                         else str <> "\n" <> line)
                                                     (l1,lineNr) refType) : tl))
-                            else return (log, False, errs)
+                            else return (log, False, False, errs)
                     (Right (WarningLine str1),(LogRef span rootPath str (l1,l2) isError):tl) ->
                         if inError
-                            then return (log, True, ((LogRef span
+                            then return (log, True, False, ((LogRef span
                                                     rootPath
                                                     (if T.null str
                                                         then line
                                                         else str <> "\n" <> line)
                                                     (l1,lineNr) WarningRef) : tl))
-                            else return (log, False, errs)
-                    otherwise -> return (log, False, errs)
+                            else return (log, False, False, errs)
+                    otherwise -> return (log, False, False, errs)
             ToolOutput line -> do
-                Log.appendLog log logLaunch (line <> "\n") LogTag
-                return (log, inError, errs)
+                case (parse docTestParser "" $ T.unpack line, inDocTest, errs) of
+                    (Right (span, exp), _, _) -> do
+                        logLn <- Log.appendLog log logLaunch (line <> "\n") ErrorTag
+                        return (log, inError, True, LogRef span
+                                            package
+                                            exp
+                                            (logLn,logLn) ErrorRef : errs)
+                    (_, True, (LogRef span rootPath str (l1,l2) refType):tl) -> do
+                        logLn <- Log.appendLog log logLaunch (line <> "\n") ErrorTag
+                        return (log, inError, inDocTest, LogRef span
+                                            rootPath
+                                            (str <> "\n" <> line)
+                                            (l1,logLn) ErrorRef : tl)
+                    _ -> do
+                        Log.appendLog log logLaunch (line <> "\n") LogTag
+                        return (log, inError, False, errs)
             ToolInput line -> do
                 Log.appendLog log logLaunch (line <> "\n") InputTag
-                return (log, inError, errs)
+                return (log, inError, inDocTest, errs)
             ToolPrompt line -> do
                 unless (T.null line) $ Log.appendLog log logLaunch (line <> "\n") LogTag >> return ()
                 let errorNum    =   length (filter isError errs)
@@ -542,7 +574,7 @@
                     [] -> defaultLineLogger' log logLaunch output
                     _ -> Log.appendLog log logLaunch (T.pack $ "- - - " ++ show errorNum ++ " errors - "
                                             ++ show warnNum ++ " warnings - - -\n") FrameTag
-                return (log, inError, errs)
+                return (log, inError, inDocTest, errs)
             ToolExit _ -> do
                 let errorNum    =   length (filter isError errs)
                 let warnNum     =   length errs - errorNum
@@ -550,7 +582,7 @@
                     [] -> defaultLineLogger' log logLaunch output
                     _ -> Log.appendLog log logLaunch (T.pack $ "----- " ++ show errorNum ++ " errors -- "
                                             ++ show warnNum ++ " warnings -----\n") FrameTag
-                return (log, inError, errs)
+                return (log, inError, inDocTest, errs)
 
 
 --logOutputLines :: Text -- ^ logLaunch
diff --git a/src/IDE/Package.hs b/src/IDE/Package.hs
--- a/src/IDE/Package.hs
+++ b/src/IDE/Package.hs
@@ -94,7 +94,6 @@
 import IDE.LogRef
 import Distribution.ModuleName (ModuleName(..))
 import Data.List (isInfixOf, nub, foldl', delete)
-import qualified System.IO.UTF8 as UTF8  (readFile)
 import IDE.Utils.Tool (ToolOutput(..), runTool, newGhci, ToolState(..), toolline)
 import qualified Data.Set as  Set (fromList)
 import qualified Data.Map as  Map (empty, fromList)
@@ -199,16 +198,15 @@
                     continuation False
                     return()
 
-runCabalBuild :: Bool -> Bool -> Bool -> Bool -> IDEPackage -> Bool -> (Bool -> IDEAction) -> IDEAction
-runCabalBuild backgroundBuild runTests jumpToWarnings withoutLinking package shallConfigure continuation = do
+runCabalBuild :: Bool -> Bool -> Bool -> IDEPackage -> Bool -> (Bool -> IDEAction) -> IDEAction
+runCabalBuild backgroundBuild jumpToWarnings withoutLinking package shallConfigure continuation = do
     prefs <- readIDE prefs
     let dir =  ipdBuildDir package
-    let args = ([if runTests then "test" else "build"]
+    let args = (["build"]
                 ++ (if backgroundBuild && withoutLinking
                     then ["--with-ld=false"]
                     else [])
-                ++ ipdBuildFlags package
-                ++ (if runTests then ipdTestFlags package else []))
+                ++ ipdBuildFlags package)
     runExternalTool' (__ "Building") (cabalCommand prefs) args dir $ do
         (mbLastOutput, isConfigErr, _) <- C.getZipSink $ (,,)
             <$> C.ZipSink sinkLast
@@ -219,7 +217,7 @@
             if shallConfigure && isConfigErr
                 then
                     packageConfig' package (\ b ->
-                        when b $ runCabalBuild backgroundBuild runTests jumpToWarnings withoutLinking package False continuation)
+                        when b $ runCabalBuild backgroundBuild jumpToWarnings withoutLinking package False continuation)
                 else do
                     continuation (mbLastOutput == Just (ToolExit ExitSuccess))
                     return ()
@@ -233,8 +231,8 @@
     str2 = __ "please re-configure"
     str3 = __ "cannot satisfy -package-id"
 
-buildPackage :: Bool -> Bool -> Bool -> Bool -> IDEPackage -> (Bool -> IDEAction) -> IDEAction
-buildPackage backgroundBuild runTests jumpToWarnings withoutLinking package continuation = catchIDE (do
+buildPackage :: Bool -> Bool -> Bool -> IDEPackage -> (Bool -> IDEAction) -> IDEAction
+buildPackage backgroundBuild jumpToWarnings withoutLinking package continuation = catchIDE (do
     ideR      <- ask
     prefs     <- readIDE prefs
     maybeDebug <- readIDE debugState
@@ -247,12 +245,12 @@
                     when (not backgroundBuild) $ liftIO $ do
                         timeoutAddFull (do
                             reflectIDE (do
-                                buildPackage backgroundBuild runTests jumpToWarnings withoutLinking
+                                buildPackage backgroundBuild jumpToWarnings withoutLinking
                                                 package continuation
                                 return False) ideR
                             return False) priorityDefaultIdle 1000
                         return ()
-                else runCabalBuild backgroundBuild runTests jumpToWarnings withoutLinking package True $ \f -> do
+                else runCabalBuild backgroundBuild jumpToWarnings withoutLinking package True $ \f -> do
                         when f $ do
                             mbURI <- readIDE autoURI
                             case mbURI of
@@ -451,7 +449,7 @@
                     packageConfig' packWithNewFlags $ \ ok -> when ok $ do
                         packageRunJavaScript' False packWithNewFlags
                 _  -> return ()
-        else liftIDE $ buildPackage False False True False package $ \ ok -> when ok $ liftIDE $ catchIDE (do
+        else liftIDE $ buildPackage False False True package $ \ ok -> when ok $ liftIDE $ catchIDE (do
                 ideR        <- ask
                 maybeDebug   <- readIDE debugState
                 pd <- liftIO $ readPackageDescription normal (ipdCabalFile package) >>= return . flattenPackageDescription
@@ -516,7 +514,7 @@
           catchIDE (do
             prefs <- readIDE prefs
             let dir = ipdBuildDir package
-            runExternalTool' (__ "Testing") (cabalCommand prefs) (["test"]
+            runExternalTool' (__ "Testing") (cabalCommand prefs) (["test", "--with-ghc=leksahtrue"]
                 ++ ipdBuildFlags package ++ ipdTestFlags package) dir $ do
                     (mbLastOutput, isConfigErr, _) <- C.getZipSink $ (,,)
                         <$> C.ZipSink sinkLast
@@ -792,7 +790,7 @@
                             -- Lets build to make sure the binaries are up to date
                             mbPackage   <- readIDE activePack
                             case mbPackage of
-                                Just package -> runCabalBuild True False False False package True (\ _ -> return ())
+                                Just package -> runCabalBuild True False False package True (\ _ -> return ())
                                 Nothing -> return ()
                 return ()
             _ -> do
diff --git a/src/IDE/Pane/Info.hs b/src/IDE/Pane/Info.hs
--- a/src/IDE/Pane/Info.hs
+++ b/src/IDE/Pane/Info.hs
@@ -48,7 +48,7 @@
         scrolledWindowSetPolicy, castToWidget, ScrolledWindow)
 import Graphics.UI.Gtk.General.Enums (PolicyType(..))
 import System.Glib.Signals (on)
-import Control.Monad (unless, void, when)
+import Control.Monad (unless, void)
 import Data.Foldable (forM_)
 import qualified Data.Text as T (unpack, pack, null)
 import Data.Monoid ((<>))
diff --git a/src/IDE/Pane/Modules.hs b/src/IDE/Pane/Modules.hs
--- a/src/IDE/Pane/Modules.hs
+++ b/src/IDE/Pane/Modules.hs
@@ -67,7 +67,6 @@
 import Graphics.UI.Editor.Simple
        (textEditor, boolEditor, staticListEditor)
 import Graphics.UI.Editor.Composite (maybeEditor)
-import qualified System.IO.UTF8 as UTF8  (writeFile)
 import IDE.Utils.GUIUtils (stockIdFromType, __)
 import IDE.Metainfo.Provider
        (getSystemInfo, getWorkspaceInfo, getPackageInfo)
diff --git a/src/IDE/Pane/PackageEditor.hs b/src/IDE/Pane/PackageEditor.hs
--- a/src/IDE/Pane/PackageEditor.hs
+++ b/src/IDE/Pane/PackageEditor.hs
@@ -86,7 +86,7 @@
 import Control.Event (EventSource(..))
 
 import qualified Graphics.UI.Gtk.Gdk.Events as GTK (Event(..))
-import Data.List (isPrefixOf, sort, nub)
+import Data.List (isPrefixOf, sort, nub, sortBy)
 import Data.Text (Text)
 import Control.Monad.Trans.Reader (ask)
 import Control.Monad.IO.Class (MonadIO(..))
@@ -521,9 +521,15 @@
                                         else Benchmark (T.unpack s) fb (buildInfos !! bii) False) benchmarks'
             mbLib = case mbLib' of
                     Nothing -> Nothing
+#if MIN_VERSION_Cabal(1,22,0)
+                    Just (Library' mn rmn rs es b bii) -> if bii + 1 > length buildInfos
+                                        then Just (Library mn rmn rs es b (buildInfos !! (length buildInfos - 1)))
+                                        else Just (Library mn rmn rs es b (buildInfos !! bii))
+#else
                     Just (Library' mn b bii) -> if bii + 1 > length buildInfos
                                         then Just (Library mn b (buildInfos !! (length buildInfos - 1)))
                                         else Just (Library mn b (buildInfos !! bii))
+#endif
     in pd {
         library = mbLib
       , executables = exes
@@ -542,7 +548,11 @@
             bis = exeBis ++ testBis ++ benchmarkBis
             (mbLib,bis2) = case library pd of
                     Nothing                -> (Nothing,bis)
+#if MIN_VERSION_Cabal(1,22,0)
+                    Just (Library mn rmn rs es b bi) -> (Just (Library' (sort mn) rmn rs es b (length bis)), bis ++ [bi])
+#else
                     Just (Library mn b bi) -> (Just (Library' (sort mn) b (length bis)), bis ++ [bi])
+#endif
             bis3 = if null bis2
                         then [emptyBuildInfo]
                         else bis2
@@ -800,10 +810,22 @@
 --            (\ a b -> b{pd = (pd b){license = a}})
 --            (comboSelectionEditor [GPL, LGPL, BSD3, BSD4, PublicDomain, AllRightsReserved, OtherLicense] show)
     ,   mkField
+#if MIN_VERSION_Cabal(1,22,0)
+            (paraName <<<- ParaName (__ "License Files")
+                $ paraSynopsis <<<- ParaSynopsis
+                    (__ "A list of license files.")
+                    $ paraDirection <<<- ParaDirection Vertical
+                        $ paraMinSize <<<- ParaMinSize (-1,250)
+                            $ emptyParams)
+            (licenseFiles . pd)
+            (\ a b -> b{pd = (pd b){licenseFiles = a}})
+            (filesEditor (Just fp) FileChooserActionOpen (__ "Select File"))
+#else
             (paraName <<<- ParaName (__ "License File") $ emptyParams)
             (licenseFile . pd)
             (\ a b -> b{pd = (pd b){licenseFile = a}})
             (fileEditor (Just fp) FileChooserActionOpen (__ "Select file"))
+#endif
     ,   mkField
             (paraName <<<- ParaName (__ "Copyright") $ emptyParams)
             (copyright . pd)
@@ -848,9 +870,9 @@
                 $ paraSynopsis <<<- ParaSynopsis
                     (__ "Does this package depends on a specific version of Cabal?")
                     $ paraShadow <<<- ParaShadow ShadowIn $ emptyParams)
-            (descCabalVersion . pd)
-            (\ a b -> b{pd = (pd b){specVersionRaw = Right a}})
-            versionRangeEditor
+            (specVersion . pd)
+            (\ a b -> b{pd = (pd b){specVersionRaw = Left a}})
+            versionEditor
     ,   mkField
             (paraName <<<- ParaName (__ "Tested with compiler")
                 $ paraShadow <<<- ParaShadow ShadowIn
@@ -1035,9 +1057,23 @@
                             $ paraShadow  <<<- ParaShadow ShadowIn $ emptyParams))
                 Nothing
                 Nothing)
+#if MIN_VERSION_Cabal(1,22,0)
      ,  mkField
             (paraName <<<- ParaName (__ "Additional options for GHC when built with profiling")
            $ emptyParams)
+            (profOptions . (\a -> a !! i) . bis)
+            (\ a b -> b{bis = update (bis b) i (\bi -> bi{profOptions = a})})
+            compilerOptsEditor
+     ,  mkField
+            (paraName <<<- ParaName (__ "Additional options for GHC when the package is built as shared library")
+           $ emptyParams)
+            (sharedOptions . (\a -> a !! i) . bis)
+            (\ a b -> b{bis = update (bis b) i (\bi -> bi{sharedOptions = a})})
+            compilerOptsEditor
+#else
+     ,  mkField
+            (paraName <<<- ParaName (__ "Additional options for GHC when built with profiling")
+           $ emptyParams)
             (ghcProfOptions . (\a -> a !! i) . bis)
             (\ a b -> b{bis = update (bis b) i (\bi -> bi{ghcProfOptions = a})})
             optsEditor
@@ -1047,6 +1083,7 @@
             (ghcSharedOptions . (\a -> a !! i) . bis)
             (\ a b -> b{bis = update (bis b) i (\bi -> bi{ghcSharedOptions = a})})
             optsEditor
+#endif
     ]),
     ((T.pack $ printf (__ "%s Extensions ") (show (i + 1))), VFD emptyParams [
         mkField
@@ -1200,6 +1237,34 @@
                 Just str -> return (Just (words str))
     return (wid,oinj,oext)
 
+compilerOptRecordEditor :: Editor (CompilerFlavor, [String])
+compilerOptRecordEditor para noti = do
+    pairEditor
+        (compilerFlavorEditor
+            , paraName <<<- ParaName "Compiler" $ emptyParams)
+        (optsEditor,paraName <<<- ParaName "Options" $ emptyParams)
+        (paraDirection <<<- ParaDirection Vertical $ para)
+        noti
+
+compilerOptsEditor :: Editor [(CompilerFlavor, [String])]
+compilerOptsEditor p noti =
+    multisetEditor
+        (ColumnDescr True [("Compiler",\(compiler, _) -> [cellText := T.pack $ show compiler])
+                           ,("Options",\(_, opts    ) -> [cellText := T.pack $ unwords opts])])
+        (compilerOptRecordEditor,
+            paraOuterAlignment <<<- ParaInnerAlignment (0.0, 0.5, 1.0, 1.0)
+                $ paraInnerAlignment <<<- ParaOuterAlignment (0.0, 0.5, 1.0, 1.0)
+                   $ emptyParams)
+        (Just (sortBy (\ (f1, _) (f2, _) -> compare f1 f2)))
+        (Just (\ (f1, _) (f2, _) -> f1 == f2))
+        (paraShadow <<<- ParaShadow ShadowIn
+            $ paraOuterAlignment <<<- ParaInnerAlignment (0.0, 0.5, 1.0, 1.0)
+                $ paraInnerAlignment <<<- ParaOuterAlignment (0.0, 0.5, 1.0, 1.0)
+                    $ paraDirection  <<<-  ParaDirection Vertical
+                        $ paraPack <<<- ParaPack PackGrow
+                            $ p)
+        noti
+
 packageEditor :: Editor PackageIdentifier
 packageEditor para noti = do
     (wid,inj,ext) <- pairEditor
@@ -1379,9 +1444,14 @@
 -- ------------------------------------------------------------
 
 data Library' = Library'{
-    exposedModules' :: [ModuleName]
-,   libExposed'     :: Bool
-,   libBuildInfoIdx :: Int}
+    exposedModules'    :: [ModuleName]
+#if MIN_VERSION_Cabal(1,22,0)
+,   reexportedModules' :: [ModuleReexport]
+,   requiredSignatures':: [ModuleName]
+,   exposedSignatures' :: [ModuleName]
+#endif
+,   libExposed'        :: Bool
+,   libBuildInfoIdx    :: Int}
     deriving (Show, Eq)
 
 data Executable' = Executable'{
@@ -1403,7 +1473,11 @@
     deriving (Show, Eq)
 
 instance Default Library'
+#if MIN_VERSION_Cabal(1,22,0)
+    where getDefault =  Library' [] [] [] [] getDefault getDefault
+#else
     where getDefault =  Library' [] getDefault getDefault
+#endif
 
 instance Default Executable'
     where getDefault = Executable' getDefault getDefault getDefault
@@ -1414,9 +1488,62 @@
 instance Default Benchmark'
     where getDefault = Benchmark' getDefault (BenchmarkExeV10 (Version [1,0] []) getDefault) getDefault
 
+#if MIN_VERSION_Cabal(1,22,0)
 libraryEditor :: Maybe FilePath -> [ModuleName] -> Int -> Editor Library'
 libraryEditor fp modules numBuildInfos para noti = do
     (wid,inj,ext) <-
+        pairEditor
+            (tupel3Editor
+                (boolEditor,
+                paraName <<<- ParaName (__ "Exposed")
+                $ paraSynopsis <<<- ParaSynopsis (__ "Is the lib to be exposed by default?")
+                $ emptyParams)
+                (modulesEditor (sort modules),
+                paraName <<<- ParaName (__ "Exposed Modules")
+                $ paraMinSize <<<- ParaMinSize (-1,300)
+                $ para)
+                (buildInfoEditorP numBuildInfos, paraName <<<- ParaName (__ "Build Info")
+                $ paraPack <<<- ParaPack PackNatural
+                $ para),
+                (paraDirection <<<- ParaDirection Vertical
+                $ emptyParams))
+            (tupel3Editor
+                (modulesEditor (sort modules),
+                paraName <<<- ParaName (__ "Reexported Modules")
+                $ paraMinSize <<<- ParaMinSize (-1,300)
+                $ para)
+                (modulesEditor (sort modules),
+                paraName <<<- ParaName (__ "Required Signatures")
+                $ paraMinSize <<<- ParaMinSize (-1,300)
+                $ para)
+                (modulesEditor (sort modules),
+                paraName <<<- ParaName (__ "Exposed Signatures")
+                $ paraMinSize <<<- ParaMinSize (-1,300)
+                $ para),
+                (paraDirection <<<- ParaDirection Vertical
+                $ emptyParams))
+            (paraDirection <<<- ParaDirection Vertical
+            $ emptyParams)
+            noti
+    let pinj (Library' em rmn rs es exp bi) = inj ((exp, map (T.pack . display) em,bi), (map (T.pack . display) rmn, map (T.pack . display) rs, map (T.pack . display) es))
+        parseModuleNames = map (\s -> forceJust (simpleParse $ T.unpack s)
+                    "SpecialEditor >> libraryEditor: no parse for moduile name")
+        parseRexportedModules = map (\s -> forceJust (simpleParse $ T.unpack s)
+                    "SpecialEditor >> libraryEditor: no parse for moduile name")
+        pext = do
+            mbp <- ext
+            case mbp of
+                Nothing -> return Nothing
+                Just ((exp,em,bi), (rmn, rs, es)) -> return (Just $ Library'
+                    (parseModuleNames em)
+                    (parseRexportedModules rmn)
+                    (parseModuleNames rs)
+                    (parseModuleNames es) exp bi)
+    return (wid,pinj,pext)
+#else
+libraryEditor :: Maybe FilePath -> [ModuleName] -> Int -> Editor Library'
+libraryEditor fp modules numBuildInfos para noti = do
+    (wid,inj,ext) <-
         tupel3Editor
             (boolEditor,
             paraName <<<- ParaName (__ "Exposed")
@@ -1440,6 +1567,7 @@
             Just (exp,em,bi) -> return (Just $ Library' (map (\s -> forceJust (simpleParse $ T.unpack s)
                 "SpecialEditor >> libraryEditor: no parse for moduile name") em) exp bi)
     return (wid,pinj,pext)
+#endif
 
 modulesEditor :: [ModuleName] -> Editor [Text]
 modulesEditor modules   =   staticListMultiEditor (map (T.pack . display) modules) id
@@ -1591,7 +1719,11 @@
     where getDefault =  emptyBuildInfo
 
 instance Default Library
-    where getDefault =  Library [] getDefault getDefault
+    where getDefault =  Library []
+#if MIN_VERSION_Cabal(1,22,0)
+                            [] [] []
+#endif
+                            getDefault getDefault
 
 instance Default Executable
     where getDefault = Executable getDefault getDefault getDefault
diff --git a/src/IDE/Pane/PackageFlags.hs b/src/IDE/Pane/PackageFlags.hs
--- a/src/IDE/Pane/PackageFlags.hs
+++ b/src/IDE/Pane/PackageFlags.hs
@@ -45,7 +45,6 @@
      FieldDescriptionPP(..),
      mkFieldPP)
 import Text.ParserCombinators.Parsec hiding(Parser)
-import Debug.Trace (trace)
 import IDE.Utils.GUIUtils (__)
 import Control.Monad (void)
 import Data.Text (Text)
diff --git a/src/IDE/Pane/Preferences.hs b/src/IDE/Pane/Preferences.hs
--- a/src/IDE/Pane/Preferences.hs
+++ b/src/IDE/Pane/Preferences.hs
@@ -71,7 +71,7 @@
 import Control.Exception(SomeException,catch)
 import Prelude hiding(catch)
 import Data.List (isSuffixOf, sortBy)
-import Data.Maybe (fromMaybe, isJust)
+import Data.Maybe (catMaybes, fromMaybe, isJust)
 import Graphics.UI.Gtk.Windows.MessageDialog
        (ButtonsType(..), MessageType(..))
 import System.Glib.Attributes (set)
@@ -84,6 +84,7 @@
 import qualified Data.Text as T (isSuffixOf, unpack, pack, null)
 import Data.Monoid ((<>))
 import Control.Applicative ((<$>))
+import Distribution.Text (display, simpleParse)
 
 -- ---------------------------------------------------------------------
 -- This needs to be incremented, when the preferences format changes
@@ -612,8 +613,8 @@
                 (__ "Packages which are excluded from the modules pane")
                         $ paraMinSize <<<- ParaMinSize (-1,200)
                             $ emptyParams)
-            (PP.text . show)
-            readParser
+            (PP.text . show . map display)
+            (fmap (catMaybes . map simpleParse) readParser)
             packageBlacklist
             (\b a -> a{packageBlacklist = b})
             (dependenciesEditor packages)
@@ -815,7 +816,7 @@
                                 ,   ("*Variables","LogCategory")
                                 ,   ("*Workspace","LogCategory")]
     ,   collectAtStart      =   True
-    ,   unpackDirectory     =   Nothing
+    ,   unpackDirectory     =   Just ("~" </> configDirName </> "packageSources")
     ,   retrieveURL         =   "http://www.leksah.org"
     ,   retrieveStrategy    =   SP.RetrieveThenBuild
     ,   useCtrlTabFlipping  =   True
diff --git a/src/IDE/Pane/SourceBuffer.hs b/src/IDE/Pane/SourceBuffer.hs
--- a/src/IDE/Pane/SourceBuffer.hs
+++ b/src/IDE/Pane/SourceBuffer.hs
@@ -103,7 +103,6 @@
 import IDE.SymbolNavigation
 import IDE.Completion as Completion (complete,cancel)
 import IDE.TextEditor
-import qualified System.IO.UTF8 as UTF8
 import Data.IORef (writeIORef,readIORef,newIORef)
 import Control.Event (triggerEvent)
 import IDE.Metainfo.Provider (getSystemInfo, getWorkspaceInfo)
@@ -792,7 +791,7 @@
         Nothing -> return ()
         Just fn -> liftIDE $ do
             buffer <- getBuffer sv
-            fc <- liftIO $ UTF8.readFile fn
+            fc <- liftIO $ readFile fn
             mt <- liftIO $ getModificationTime fn
             beginNotUndoableAction buffer
             setText buffer $ T.pack fc
diff --git a/src/IDE/Pane/WebKit/Inspect.hs b/src/IDE/Pane/WebKit/Inspect.hs
--- a/src/IDE/Pane/WebKit/Inspect.hs
+++ b/src/IDE/Pane/WebKit/Inspect.hs
@@ -96,11 +96,11 @@
 instance RecoverablePane IDEInspect InspectState IDEM where
     saveState p     =   liftIO $ do
 #ifdef WEBKITGTK
-        return (Just InspectState{..})
+        return (Just InspectState{})
 #else
         Just <$> readIORef (inspectState p)
 #endif
-    recoverState pp InspectState {..} = do
+    recoverState pp InspectState {} = do
         nb      <-  getNotebook pp
         mbPane <- buildPane pp nb builder
         case mbPane of
diff --git a/src/IDE/Pane/WebKit/Output.hs b/src/IDE/Pane/WebKit/Output.hs
--- a/src/IDE/Pane/WebKit/Output.hs
+++ b/src/IDE/Pane/WebKit/Output.hs
@@ -155,7 +155,7 @@
             liftIO $ case (key, mod) of
                 ("plus", [Shift,Control]) -> webViewZoomIn  webView >> return True
                 ("minus",[Control])       -> webViewZoomOut webView >> return True
-                ("BackSpace", [])         -> webViewGoBack  webView >> return True
+                ("BackSpace", [Shift])    -> webViewGoBack  webView >> return True
                 _                         -> return False
 
         cid3 <- on webView populatePopup $ \ menu -> do
diff --git a/src/IDE/Session.hs b/src/IDE/Session.hs
--- a/src/IDE/Session.hs
+++ b/src/IDE/Session.hs
@@ -429,11 +429,11 @@
         dialog <- fileChooserDialogNew
                   (Just $ (__ "Select session file"))
                   (Just window')
-    	      FileChooserActionOpen
-    	      [("gtk-cancel"
-    	       ,ResponseCancel)
-    	      ,("gtk-open"
-    	       , ResponseAccept)]
+              FileChooserActionOpen
+              [("gtk-cancel"
+               ,ResponseCancel)
+              ,("gtk-open"
+               , ResponseAccept)]
         fileChooserSetCurrentFolder dialog configFolder
         widgetShow dialog
         res <- dialogRun dialog
diff --git a/src/IDE/Utils/GUIUtils.hs b/src/IDE/Utils/GUIUtils.hs
--- a/src/IDE/Utils/GUIUtils.hs
+++ b/src/IDE/Utils/GUIUtils.hs
@@ -129,11 +129,9 @@
     dialog <- fileChooserDialogNew
               (Just $ prompt)
               (Just window)
-	      FileChooserActionSave
-	      [("gtk-cancel"
-	       ,ResponseCancel)
-	      ,("gtk-save"
-          , ResponseAccept)]
+              FileChooserActionSave
+              [("gtk-cancel", ResponseCancel)
+              ,("gtk-save",   ResponseAccept)]
     when (isJust mbFolder) $ fileChooserSetCurrentFolder dialog (fromJust mbFolder)  >> return ()
     widgetShow dialog
     res <- dialogRun dialog
diff --git a/src/IDE/Utils/ServerConnection.hs b/src/IDE/Utils/ServerConnection.hs
--- a/src/IDE/Utils/ServerConnection.hs
+++ b/src/IDE/Utils/ServerConnection.hs
@@ -26,17 +26,37 @@
 import System.IO
 import Control.Exception (SomeException(..), catch)
 import Prelude hiding(catch)
-import Control.Concurrent(forkIO)
+import Control.Concurrent(forkIO, newEmptyMVar, putMVar, takeMVar, tryTakeMVar)
 import Graphics.UI.Gtk(postGUIAsync)
 import Control.Event(triggerEvent)
 import Control.Monad.IO.Class (MonadIO(..))
-import System.Log.Logger (getLevel, getRootLogger)
-import Control.Monad (void)
+import Control.Monad.Reader (ask)
+import System.Log.Logger (getLevel, getRootLogger, debugM)
+import Control.Monad (void, forever)
 import qualified Data.Text as T (pack, unpack)
 import Data.Monoid ((<>))
 
-doServerCommand :: ServerCommand -> (ServerAnswer -> IDEM alpha) -> IDEAction
+doServerCommand :: ServerCommand -> (ServerAnswer -> IDEM ()) -> IDEAction
 doServerCommand command cont = do
+    q' <- readIDE serverQueue
+    q <- case q' of
+        Just q -> return q
+        Nothing -> do
+            q <- liftIO $ newEmptyMVar
+            modifyIDE_ (\ ide -> ide{serverQueue = Just q})
+            ideR <- ask
+            liftIO . forkIO . forever $ do
+                debugM "leksah" $ "Ready for command"
+                (command, cont) <- takeMVar q
+                reflectIDE (doServerCommand' command cont) ideR
+            return q
+    liftIO $ do
+        tryTakeMVar q
+        debugM "leksah" $ "Queue new command " ++ show command
+        putMVar q (command, cont)
+
+doServerCommand' :: ServerCommand -> (ServerAnswer -> IDEM ()) -> IDEAction
+doServerCommand' command cont = do
     server' <- readIDE server
     case server' of
         Just handle -> do
@@ -62,15 +82,17 @@
             return ()
     where
         doCommand handle = do
-            triggerEventIDE (StatusbarChanged [CompartmentCollect True])
-            reifyIDE $ \ideR -> forkIO $ do
+            postAsyncIDE . void $ triggerEventIDE (StatusbarChanged [CompartmentCollect True])
+            resp <- liftIO $ do
+                debugM "leksah" $ "Sending server command " ++ show command
                 hPrint handle command
                 hFlush handle
-                resp <- hGetLine handle
-                postGUIAsync (reflectIDE (do
-                        triggerEvent ideR (StatusbarChanged [CompartmentCollect False])
-                        cont (read resp)
-                        return ()) ideR)
+                debugM "leksah" $ "Waiting on server command " ++ show command
+                hGetLine handle
+            liftIO . debugM "leksah" $ "Server result " ++ resp
+            postAsyncIDE $ do
+                triggerEventIDE (StatusbarChanged [CompartmentCollect False])
+                cont (read resp)
 
 startServer :: Int -> IO ()
 startServer port = do
diff --git a/src/IDE/Workspaces.hs b/src/IDE/Workspaces.hs
--- a/src/IDE/Workspaces.hs
+++ b/src/IDE/Workspaces.hs
@@ -74,7 +74,6 @@
 import qualified Control.Exception as Exc (SomeException(..), throw, Exception)
 import qualified Data.Map as  Map (empty)
 import IDE.Pane.SourceBuffer (fileOpenThis, fileCheckAll, belongsToPackages)
-import qualified System.IO.UTF8 as UTF8 (writeFile)
 import System.Glib.Attributes (AttrOp(..), set)
 import Graphics.UI.Gtk.General.Enums (WindowPosition(..))
 import Control.Applicative ((<$>))
@@ -437,7 +436,7 @@
     debug <- isJust <$> readIDE debugState
     return $ case (runTests, debug) of
                 (True, True)   -> [MoBuild,MoDocu]
-                (True, False)  -> [MoBuild,MoDocu,MoCopy,MoRegister]
+                (True, False)  -> [MoBuild,MoDocu,MoTest,MoCopy,MoRegister]
                 (False, True)  -> [MoBuild]
                 (False, False) -> [MoBuild,MoCopy,MoRegister]
 
diff --git a/tests/Tests.hs b/tests/Tests.hs
--- a/tests/Tests.hs
+++ b/tests/Tests.hs
@@ -28,7 +28,7 @@
 import System.Log (Priority(..))
 import Control.Concurrent
        (yield, takeMVar, putMVar, newEmptyMVar, threadDelay, forkIO)
-import System.Glib.MainLoop (priorityHigh)
+import System.Glib.MainLoop (priorityLow)
 import Data.Monoid ((<>))
 
 testString =    "    Could not find module `Graphics.UI.Gtk':\n"
@@ -52,7 +52,7 @@
         updateGlobalLogger rootLoggerName (setLevel DEBUG)
         allPass <- $quickCheckAll -- Run QuickCheck on all prop_ functions
         initGUI
-        timeoutAddFull (yield >> return True) priorityHigh 10
+        timeoutAddFull (yield >> return True) priorityLow 10
         editorsOk <- testEditors
         putMVar result (allPass && editorsOk)
     forkIO $ do
diff --git a/win32/makeinstaller.sh b/win32/makeinstaller.sh
--- a/win32/makeinstaller.sh
+++ b/win32/makeinstaller.sh
@@ -1,120 +1,142 @@
-#!/bin/sh
-
-. scripts/stage.sh || exit
-
-export CABAL_USER_BIN=$HOME/AppData/Roaming/cabal/bin
-export GHC_USER_PREFIX=$HOME/AppData/Roaming/cabal/x86_64-windows-ghc-`ghc$GHCVERSION --numeric-version`
-export LEKSAH_PREFIX=$GHC_USER_PREFIX
-export LEKSAH_SERVER_PREFIX=$GHC_USER_PREFIX
-export HLINT_X_X_X_X=`ghc-pkg$GHCVERSION list |grep '^ *hlint-' | tail -n1 | tr -d ' \n'`
-export PRETTY_SHOW_X_X=`ghc-pkg$GHCVERSION list |grep '^ *pretty-show-' | tail -n1 | tr -d ' \n'`
-export GHCJS_CODEMIRROR_X_X_X_X=`ghc-pkg$GHCVERSION list |grep '^ *ghcjs-codemirror-' | tail -n1 | tr -d ' \n'`
-
-sed 's|\<ctrl\>q|\<alt\>F4|' <data/keymap.lkshk >"$LEKSAH_PREFIX/$LEKSAH_X_X_X_X/data/keymap.lkshk" || exit
-
-cd win32 || exit
-
-export MINGW_BIN=`cmd //C echo \`dirname \\\`which gcc\\\`\``
-export PATH=$PATH:/c/Program\ Files\ \(x86\)/NSIS:/c/Program\ Files/NSIS
-#makensis leksah.nsi
-
-export PATH=$PATH:/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.8/bin:/c/Program\ Files/WiX\ Toolset\ v3.8/bin
-mkdir -p SourceDir
-cp -ru leksah.bat SourceDir
-cp -ru leksah-server.bat SourceDir
-cp -ru leksah-rebuild-metadata.bat SourceDir
-cp -ru "$GTK_PREFIX"/etc SourceDir
-mkdir -p SourceDir/leksah
-cp -ru "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/data SourceDir/leksah
-cp -ru "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/language-specs SourceDir/leksah
-cp -ru "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/pics SourceDir/leksah
-cp -u  "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/LICENSE SourceDir/leksah
-cp -u  "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/Readme.md SourceDir/leksah
-mkdir -p SourceDir/hlint
-cp -ru "$LEKSAH_PREFIX/$HLINT_X_X_X_X"/* SourceDir/hlint
-mkdir -p SourceDir/pretty-show
-cp -ru "$LEKSAH_PREFIX/$PRETTY_SHOW_X_X"/style SourceDir/pretty-show
-mkdir -p SourceDir/ghcjs-codemirror
-cp -ru "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/mode SourceDir/ghcjs-codemirror
-cp -ru "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/lib SourceDir/ghcjs-codemirror
-cp -ru "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/keymap SourceDir/ghcjs-codemirror
-cp -ru "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/theme SourceDir/ghcjs-codemirror
-mkdir -p SourceDir/bin
-cp -u  "$CABAL_USER_BIN"/leksah.exe SourceDir/bin
-cp -u  "$CABAL_USER_BIN"/vcswrapper.exe SourceDir/bin
-cp -u  "$CABAL_USER_BIN"/vcsgui.exe SourceDir/bin
-cp -u  "$CABAL_USER_BIN"/vcsgui-askpass.exe SourceDir/bin
-cp -u  "$CABAL_USER_BIN"/leksah-server.exe SourceDir/bin
-cp -u  "$CABAL_USER_BIN"/leksahecho.exe SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/iconv.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/icudata50.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/icui18n50.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/icule50.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/icuuc50.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libatk-1.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libbz2-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libcairo-2.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libcairo-gobject-2.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libcrypto-10.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libenchant.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libexpat-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libffi-6.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libfontconfig-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libfreetype-6.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgailutil-3-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgcc_s_seh-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgcc_s_sjlj-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgdk-3-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgdk_pixbuf-2.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgio-2.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libglib-2.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgmodule-2.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgobject-2.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgst*-1.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgthread-2.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgtk-3-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libgtksourceview-3.0-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libharfbuzz-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libharfbuzz-icu-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libidn-11.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libintl-8.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libjavascriptcoregtk-3.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libjpeg-62.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libpango-1.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libpangocairo-1.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libpangoft2-1.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libpangowin32-1.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libpixman-1-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libpng16-16.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libsoup-2.4-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libsqlite3-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libssh2-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libssl-10.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libstdc++-6.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libxml2-2.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libxslt-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libwebkitgtk-3.0-0.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libwebp-5.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/libwinpthread-1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/zlib1.dll SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/pkg-config.exe SourceDir/bin
-cp -u  "$GTK_PREFIX"/bin/grep.exe SourceDir/bin
-mkdir -p SourceDir/share
-cp -ru "$GTK_PREFIX"/share/themes SourceDir/share
-cp -ru "$GTK_PREFIX"/share/icons SourceDir/share
-cp -ru "$GTK_PREFIX"/share/glib-2.0 SourceDir/share
-cp -ru "$GTK_PREFIX"/share/gtksourceview-3.0 SourceDir/share
-mkdir -p SourceDir/libexec
-cp -ru "$GTK_PREFIX"/libexec/gstreamer-1.0 SourceDir/libexec
-
-cp -ru "$GTK_PREFIX"/include SourceDir
-cp -ru "$GTK_PREFIX"/lib SourceDir
-
-# mkdir -p SourceDir/fonts
-# cp -ru /c/Windows/Fonts/DejaVuS*.ttf SourceDir
-
-heat dir SourceDir -srd -gg -sfrag -template fragment -out heat.wxs -cg Leksah -dr INSTALLDIR -sreg suppress registry harvesting || exit
-candle heat.wxs || exit
-candle leksah.wxs || exit
-light -ext WixUIExtension heat.wixobj leksah.wixobj -out $LEKSAH_X_X_X_X.msi || exit
-
+#!/bin/sh -ex
+
+if ["$WINE" -eq ""]
+then
+  WINEPATH_U=echo
+  WINE_APPDATA=$APPDATA
+  LN='cp -uH'
+  LNDIR='cp -ruH'
+else
+  WINE_APPDATA=`$WINE cmd /C echo %APPDATA% | tr -d '\r\n'`
+  LN='ln -s'
+  LNDIR='ln -s'
+fi
+
+. scripts/stage.sh || exit
+
+export CABAL_USER_BIN=`$WINEPATH_U "$WINE_APPDATA"/cabal/bin`
+export GHC_USER_PREFIX=`$WINEPATH_U "$WINE_APPDATA"/cabal/x86_64-windows-ghc-\`$WINE ghc$GHCVERSION --numeric-version | tr -d '\r\n'\``
+export LEKSAH_PREFIX=$GHC_USER_PREFIX
+export LEKSAH_SERVER_PREFIX=$GHC_USER_PREFIX
+export HLINT_X_X_X_X=`$WINE ghc-pkg$GHCVERSION list |grep '^ *hlint-' | tail -n1 | tr -d ' \r\n'`
+export PRETTY_SHOW_X_X=`$WINE ghc-pkg$GHCVERSION list |grep '^ *pretty-show-' | tail -n1 | tr -d ' \r\n'`
+export GHCJS_CODEMIRROR_X_X_X_X=`$WINE ghc-pkg$GHCVERSION list |grep '^ *ghcjs-codemirror-' | tail -n1 | tr -d ' \r\n'`
+export GTK_PREFIX_U=`$WINEPATH_U "$GTK_PREFIX"`
+
+sed 's|\<ctrl\>q|\<alt\>F4|' <data/keymap.lkshk >"$LEKSAH_PREFIX/$LEKSAH_X_X_X_X/data/keymap.lkshk" || exit
+
+cd win32 || exit
+
+export PATH=$PATH:/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.8/bin:/c/Program\ Files/WiX\ Toolset\ v3.8/bin
+mkdir -p SourceDir
+cp -u leksah.bat SourceDir
+cp -u leksah-server.bat SourceDir
+cp -u leksah-rebuild-metadata.bat SourceDir
+$LNDIR "$GTK_PREFIX_U"/etc SourceDir
+mkdir -p SourceDir/leksah
+$LNDIR "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/data SourceDir/leksah
+$LNDIR "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/language-specs SourceDir/leksah
+$LNDIR "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/pics SourceDir/leksah
+$LN  "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/LICENSE SourceDir/leksah
+$LN  "$LEKSAH_PREFIX/$LEKSAH_X_X_X_X"/Readme.md SourceDir/leksah
+mkdir -p SourceDir/hlint
+$LNDIR "$LEKSAH_PREFIX/$HLINT_X_X_X_X"/* SourceDir/hlint
+mkdir -p SourceDir/pretty-show
+$LNDIR "$LEKSAH_PREFIX/$PRETTY_SHOW_X_X"/style SourceDir/pretty-show
+mkdir -p SourceDir/ghcjs-codemirror
+$LNDIR "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/mode SourceDir/ghcjs-codemirror
+$LNDIR "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/lib SourceDir/ghcjs-codemirror
+$LNDIR "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/keymap SourceDir/ghcjs-codemirror
+$LNDIR "$LEKSAH_PREFIX/$GHCJS_CODEMIRROR_X_X_X_X"/theme SourceDir/ghcjs-codemirror
+mkdir -p SourceDir/bin
+$LN  "$CABAL_USER_BIN"/leksah.exe SourceDir/bin
+$LN  "$CABAL_USER_BIN"/vcswrapper.exe SourceDir/bin
+$LN  "$CABAL_USER_BIN"/vcsgui.exe SourceDir/bin
+$LN  "$CABAL_USER_BIN"/vcsgui-askpass.exe SourceDir/bin
+$LN  "$CABAL_USER_BIN"/leksah-server.exe SourceDir/bin
+$LN  "$CABAL_USER_BIN"/leksahecho.exe SourceDir/bin
+$LN  "$CABAL_USER_BIN"/leksahtrue.exe SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/iconv.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/icudata50.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/icui18n50.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/icule50.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/icuuc50.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libatk-1.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libbz2-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libcairo-2.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libcairo-gobject-2.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libenchant.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libepoxy-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libexpat-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libexslt-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libffi-6.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libfontconfig-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libfreetype-6.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgailutil-3-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgcc_s_seh-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgdk-3-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgdk_pixbuf-2.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgio-2.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libglib-2.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgmodule-2.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgmp-10.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgnutls-28.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgobject-2.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgst*-1.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgthread-2.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgtk-3-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libgtksourceview-3.0-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libharfbuzz-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libharfbuzz-icu-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libhogweed-2-5.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libintl-8.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libjavascriptcoregtk-3.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libjpeg-62.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libnettle-4-7.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libp11-kit-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libpango-1.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libpangocairo-1.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libpangoft2-1.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libpangowin32-1.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libpixman-1-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libpng16-16.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libsoup-2.4-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libsqlite3-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libstdc++-6.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libtasn1-6.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libxml2-2.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libxslt-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libwebkitgtk-3.0-0.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libwebp-5.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/libwinpthread-1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/zlib1.dll SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/pkg-config.exe SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/grep.exe SourceDir/bin
+$LN  "$GTK_PREFIX_U"/bin/xsltproc.exe SourceDir/bin
+mkdir -p SourceDir/share
+$LNDIR "$GTK_PREFIX_U"/share/themes SourceDir/share
+$LNDIR "$GTK_PREFIX_U"/share/icons SourceDir/share
+$LNDIR "$GTK_PREFIX_U"/share/glib-2.0 SourceDir/share
+$LNDIR "$GTK_PREFIX_U"/share/gtksourceview-3.0 SourceDir/share
+mkdir -p SourceDir/libexec
+$LNDIR "$GTK_PREFIX_U"/libexec/gstreamer-1.0 SourceDir/libexec
+
+$LNDIR "$GTK_PREFIX_U"/include SourceDir
+$LNDIR "$GTK_PREFIX_U"/lib SourceDir
+
+# mkdir -p SourceDir/fonts
+# cp -ru /c/Windows/Fonts/DejaVuS*.ttf SourceDir
+export WINEPREFIX=~/.wine32
+export WINEARCH=win32
+if ["$WINE" -eq ""]
+then
+  heat dir SourceDir -srd -gg -sfrag -template fragment -out heat.wxs -cg Leksah -dr INSTALLDIR -sreg suppress registry harvesting || exit
+  LIGHT=light
+else
+  find SourceDir -follow | wixl-heat -p SourceDir/ --component-group Leksah --directory-ref INSTALLDIR > heat.wxs || exit
+  LIGHT='light -sval'
+fi
+xsltproc heat.xslt heat.wxs > heatfixed.wxs
+$WINE candle heatfixed.wxs || exit
+$WINE candle leksah.wxs || exit
+$WINE $LIGHT -ext WixUIExtension heatfixed.wixobj leksah.wixobj -out $LEKSAH_X_X_X_X_GHC_X_X_X.msi || exit
