summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml1
-rw-r--r--build_tools.sh3
-rw-r--r--ci/nsis_build.bat11
-rw-r--r--compiler.nimble2
-rw-r--r--compiler/ast.nim10
-rw-r--r--compiler/ccgtypes.nim5
-rw-r--r--compiler/ccgutils.nim5
-rw-r--r--compiler/cgen.nim11
-rw-r--r--compiler/docgen.nim2
-rw-r--r--compiler/installer.ini14
-rw-r--r--compiler/jsgen.nim9
-rw-r--r--compiler/msgs.nim2
-rw-r--r--compiler/nim.nim5
-rw-r--r--compiler/nimfix/nimfix.nim2
-rw-r--r--compiler/parampatterns.nim2
-rw-r--r--compiler/renderer.nim3
-rw-r--r--compiler/semasgn.nim7
-rw-r--r--compiler/semcall.nim2
-rw-r--r--compiler/semdestruct.nim2
-rw-r--r--compiler/semexprs.nim40
-rw-r--r--compiler/seminst.nim5
-rw-r--r--compiler/semmagic.nim2
-rw-r--r--compiler/sempass2.nim12
-rw-r--r--compiler/sigmatch.nim32
-rw-r--r--compiler/types.nim59
-rw-r--r--compiler/typesrenderer.nim18
-rw-r--r--compiler/vm.nim7
-rw-r--r--compiler/vmdeps.nim14
-rw-r--r--contributors.txt12
-rw-r--r--doc/advopt.txt1
-rw-r--r--doc/astspec.txt1
-rw-r--r--doc/contributing.rst (renamed from contributing.rst)0
-rw-r--r--doc/docs.rst (renamed from doc/docs.txt)0
-rw-r--r--doc/docstyle.rst (renamed from docstyle.rst)0
-rw-r--r--doc/gc.rst30
-rw-r--r--doc/manual/exceptions.txt2
-rw-r--r--doc/overview.rst (renamed from doc/overview.txt)2
-rw-r--r--icons/koch-amd64-windows-vcc.resbin0 -> 5572 bytes
-rw-r--r--icons/koch-i386-windows-vcc.resbin0 -> 5572 bytes
-rw-r--r--icons/nim-amd64-windows-vcc.resbin0 -> 30548 bytes
-rw-r--r--icons/nim-i386-windows-vcc.resbin0 -> 30548 bytes
-rw-r--r--install.txt12
-rw-r--r--install_nimble.nims4
-rw-r--r--install_tools.nims21
-rw-r--r--koch.nim194
-rw-r--r--lib/arch/arch.nim2
-rw-r--r--lib/core/macros.nim32
-rw-r--r--lib/impure/nre.nim8
-rw-r--r--lib/impure/re.nim9
-rw-r--r--lib/js/jsconsole.nim44
-rw-r--r--lib/packages/docutils/highlite.nim15
-rw-r--r--lib/posix/kqueue.nim2
-rw-r--r--lib/pure/asyncdispatch.nim6
-rw-r--r--lib/pure/collections/sequtils.nim4
-rw-r--r--lib/pure/collections/tables.nim47
-rw-r--r--lib/pure/future.nim21
-rw-r--r--lib/pure/httpclient.nim28
-rw-r--r--lib/pure/ioselectors.nim8
-rw-r--r--lib/pure/ioselects/ioselectors_kqueue.nim10
-rw-r--r--lib/pure/os.nim161
-rw-r--r--lib/pure/ospaths.nim4
-rw-r--r--lib/pure/osproc.nim72
-rw-r--r--lib/pure/parsexml.nim32
-rw-r--r--lib/pure/random.nim4
-rw-r--r--lib/pure/times.nim34
-rw-r--r--lib/pure/unittest.nim24
-rw-r--r--lib/pure/xmlparser.nim5
-rw-r--r--lib/stdlib.nimble2
-rw-r--r--lib/system.nim12
-rw-r--r--lib/system/dyncalls.nim5
-rw-r--r--lib/system/gc2.nim12
-rw-r--r--lib/system/gc_common.nim1
-rw-r--r--lib/system/gc_stack.nim7
-rw-r--r--lib/system/hti.nim1
-rw-r--r--lib/system/osalloc.nim2
-rw-r--r--lib/system/sysio.nim27
-rw-r--r--lib/upcoming/asyncdispatch.nim24
-rw-r--r--lib/windows/registry.nim77
-rw-r--r--lib/wrappers/openssl.nim2
-rw-r--r--readme.md18
-rw-r--r--tests/async/tasynceverror.nim66
-rw-r--r--tests/async/tgenericasync.nim14
-rw-r--r--tests/collections/ttables.nim33
-rw-r--r--tests/generics/tstatictalias.nim20
-rw-r--r--tests/js/tconsole.nim13
-rw-r--r--tests/macros/tdump.nim13
-rw-r--r--tests/osproc/tafalse.nim3
-rw-r--r--tests/osproc/texitcode.nim18
-rw-r--r--tests/osproc/tworkingdir.nim16
-rw-r--r--tests/stdlib/tgetfileinfo.nim40
-rw-r--r--tests/stdlib/ttime.nim25
-rw-r--r--tests/template/tconfusinglocal.nim13
-rw-r--r--tests/testament/categories.nim17
-rw-r--r--tests/testament/tester.nim2
-rw-r--r--tests/vm/tgorge.bat1
-rw-r--r--tests/vm/tgorge.nim12
-rw-r--r--tests/vm/tgorge.sh2
-rw-r--r--tools/finish.nim165
-rw-r--r--tools/niminst/buildbat.tmpl6
-rw-r--r--tools/niminst/buildsh.tmpl5
-rw-r--r--tools/niminst/debcreation.nim4
-rw-r--r--tools/niminst/deinstall.tmpl2
-rw-r--r--tools/niminst/install.tmpl2
-rw-r--r--tools/niminst/makefile.tmpl4
-rw-r--r--tools/niminst/niminst.nim92
-rw-r--r--tools/niminst/nsis.tmpl2
-rw-r--r--tools/nimweb.nim36
-rw-r--r--tools/noprefix.nim32
-rw-r--r--tools/start.bat (renamed from start.bat)6
-rw-r--r--web/download.rst39
-rw-r--r--web/inactive_sponsors.csv12
-rw-r--r--web/news.rst57
-rw-r--r--web/news/e001_version_0_8_6.rst (renamed from web/news/2009_12_21_version_0_8_6_released.rst)0
-rw-r--r--web/news/e002_version_0_8_8.rst (renamed from web/news/2010_03_14_version_0_8_8_released.rst)0
-rw-r--r--web/news/e003_version_0_8_10.rst (renamed from web/news/2010_10_20_version_0_8_10_released.rst)0
-rw-r--r--web/news/e004_version_0_8_12.rst (renamed from web/news/2011_07_10_version_0_8_12_released.rst)0
-rw-r--r--web/news/e005_version_0_8_14.rst (renamed from web/news/2012_02_09_version_0_8_14_released.rst)0
-rw-r--r--web/news/e006_version_0_9_0.rst (renamed from web/news/2012_09_23_version_0_9_0_released.rst)0
-rw-r--r--web/news/e007_version_0_9_2.rst (renamed from web/news/2013_05_20_version_0_9_2_released.rst)0
-rw-r--r--web/news/e008_new_website.rst (renamed from web/news/2013_05_20_new_website_design.rst)0
-rw-r--r--web/news/e009_andreas_rumpfs_talk.rst (renamed from web/news/2014_01_15_andreas_rumpfs_talk_on_nimrod.rst)0
-rw-r--r--web/news/e010_dr_dobbs_journal.rst (renamed from web/news/2014_02_11_nimrod_featured_in_dr_dobbs_journal.rst)0
-rw-r--r--web/news/e011_version_0_9_4.rst (renamed from web/news/2014_04_21_version_0_9_4_released.rst)0
-rw-r--r--web/news/e012_version_0_9_6.rst (renamed from web/news/2014_10_19_version_0_9_6_released.rst)0
-rw-r--r--web/news/e013_version_0_10_2.rst (renamed from web/news/2014_12_29_version_0_10_2_released.rst)0
-rw-r--r--web/news/e014_version_0_11_0.rst (renamed from web/news/2015_04_30_version_0_11_0_released.rst)0
-rw-r--r--web/news/e015_version_0_11_2.rst (renamed from web/news/2015_05_04_version_0_11_2_released.rst)0
-rw-r--r--web/news/e016_nim_conf1.rst (renamed from web/news/2015_10_16_first_nim_conference.rst)0
-rw-r--r--web/news/e017_version_0_12_0.rst (renamed from web/news/2015_10_27_version_0_12_0_released.rst)0
-rw-r--r--web/news/e018_oscon_amsterdam.rst (renamed from web/news/2016_01_18_andreas_rumpfs_talk_at_oscon_amsterdam.rst)0
-rw-r--r--web/news/e019_version_0_13_0.rst (renamed from web/news/2016_01_18_version_0_13_0_released.rst)0
-rw-r--r--web/news/e020_nim_in_action.rst (renamed from web/news/2016_01_27_nim_in_action_is_now_available.rst)0
-rw-r--r--web/news/e021_meet_sponsors.rst (renamed from web/news/2016_06_04_meet_our_bountysource_sponsors.rst)0
-rw-r--r--web/news/e022_version_0_14_0.rst (renamed from web/news/2016_06_07_version_0_14_0_released.rst)0
-rw-r--r--web/news/e023_version_0_14_2.rst (renamed from web/news/2016_06_11_version_0_14_2_released.rst)0
-rw-r--r--web/news/e024_survey.rst (renamed from web/news/2016_06_23_launching_the_2016_nim_community_survey.rst)0
-rw-r--r--web/news/e025_bountysource_update.rst (renamed from web/news/2016_08_06_bountysource_update_the_road_to_v10.rst)0
-rw-r--r--web/news/e026_survey_results.rst (renamed from web/news/2016_09_03_nim_community_survey_results.rst)0
-rw-r--r--web/news/e027_version_0_15_0.rst (renamed from web/news/2016_09_30_version_0_15_0_released.rst)0
-rw-r--r--web/news/e028_version_0_15_2.rst77
-rw-r--r--web/news/e029_version_0_16_0.rst53
-rw-r--r--web/sponsors.csv66
-rw-r--r--web/ticker.html14
-rw-r--r--web/website.ini6
144 files changed, 1572 insertions, 744 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 54b40dcd7..76c94c8e7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -40,6 +40,7 @@ deploy-windows:
   artifacts:
     paths:
       - build/*.exe
+      - build/*.zip
     expire_in: 1 week
   tags:
     - windows
diff --git a/build_tools.sh b/build_tools.sh
deleted file mode 100644
index 4d867b0ad..000000000
--- a/build_tools.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-./bin/nim c --noNimblePath -p:compiler -o:./bin/nimble dist/nimble/src/nimble.nim
-./bin/nim c --noNimblePath -p:compiler -o:./bin/nimsuggest dist/nimsuggest/nimsuggest.nim
-./bin/nim c -o:./bin/nimgrep tools/nimgrep.nim
diff --git a/ci/nsis_build.bat b/ci/nsis_build.bat
index f870e8e88..4e9d0d67c 100644
--- a/ci/nsis_build.bat
+++ b/ci/nsis_build.bat
@@ -21,11 +21,8 @@ cd web\upload
 move /y docs-%NIMVER%.zip download
 cd ..\..
 
-Rem Build .zip file:
-rem koch csources -d:release
-rem koch xz -d:release
-rem move /y build\nim-%NIMVER%.zip web\upload\download
-
+Rem Build csources
+koch csources -d:release || exit /b
 
 rem Grab C sources and nimsuggest
 git clone --depth 1 https://github.com/nim-lang/csources.git
@@ -43,8 +40,10 @@ ReM which mingw link to put in the NSIS installer.
 nim c --out:koch_temp koch || exit /b
 koch_temp boot -d:release || exit /b
 koch_temp nsis -d:release || exit /b
+koch_temp zip -d:release || exit /b
 dir build
 move /y build\nim_%NIMVER%.exe build\nim-%NIMVER%_x32.exe || exit /b
+move /y build\nim-%NIMVER%.zip build\nim-%NIMVER%_x32.zip || exit /b
 
 
 ReM Build Win64 version:
@@ -55,4 +54,6 @@ cd ..
 nim c --out:koch_temp koch || exit /b
 koch_temp boot -d:release || exit /b
 koch_temp nsis -d:release || exit /b
+koch_temp zip -d:release || exit /b
 move /y build\nim_%NIMVER%.exe build\nim-%NIMVER%_x64.exe || exit /b
+move /y build\nim-%NIMVER%.zip build\nim-%NIMVER%_x64.zip || exit /b
diff --git a/compiler.nimble b/compiler.nimble
index 247e2ecaf..cb3eb34f6 100644
--- a/compiler.nimble
+++ b/compiler.nimble
@@ -1,6 +1,6 @@
 [Package]
 name = "compiler"
-version = "0.15.0"
+version = "0.15.2"
 author = "Andreas Rumpf"
 description = "Compiler package providing the compiler sources as a library."
 license = "MIT"
diff --git a/compiler/ast.nim b/compiler/ast.nim
index d8939fc60..5c9252bee 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -317,6 +317,10 @@ type
   TTypeKind* = enum  # order is important!
                      # Don't forget to change hti.nim if you make a change here
                      # XXX put this into an include file to avoid this issue!
+                     # several types are no longer used (guess which), but a
+                     # spot in the sequence is kept for backwards compatibility
+                     # (apparently something with bootstrapping)
+                     # if you need to add a type, they can apparently be reused
     tyNone, tyBool, tyChar,
     tyEmpty, tyArrayConstr, tyNil, tyExpr, tyStmt, tyTypeDesc,
     tyGenericInvocation, # ``T[a, b]`` for types to invoke
@@ -345,9 +349,9 @@ type
     tyInt, tyInt8, tyInt16, tyInt32, tyInt64, # signed integers
     tyFloat, tyFloat32, tyFloat64, tyFloat128,
     tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64,
-    tyBigNum,
-    tyConst, tyMutable, tyVarargs,
-    tyIter, # unused
+    tyUnused0, tyUnused1, tyUnused2,
+    tyVarargs,
+    tyUnused,
     tyProxy # used as errornous type (for idetools)
 
     tyBuiltInTypeClass #\
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index eac734b3d..bd2e2cdda 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -122,7 +122,7 @@ proc mapType(typ: PType): TCTypeKind =
   of tyOpenArray, tyArrayConstr, tyArray, tyVarargs: result = ctArray
   of tyObject, tyTuple: result = ctStruct
   of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal,
-     tyConst, tyMutable, tyIter, tyTypeDesc:
+     tyTypeDesc:
     result = mapType(lastSon(typ))
   of tyEnum:
     if firstOrd(typ) < 0:
@@ -711,8 +711,7 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): Rope =
       of 1, 2, 4, 8: addf(m.s[cfsTypes], "typedef NU$2 $1;$n", [result, rope(s*8)])
       else: addf(m.s[cfsTypes], "typedef NU8 $1[$2];$n",
              [result, rope(getSize(t))])
-  of tyGenericInst, tyDistinct, tyOrdinal, tyConst, tyMutable,
-      tyIter, tyTypeDesc:
+  of tyGenericInst, tyDistinct, tyOrdinal, tyTypeDesc:
     result = getTypeDescAux(m, lastSon(t), check)
   else:
     internalError("getTypeDescAux(" & $t.kind & ')')
diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim
index ecd98a2bf..2216cb4fd 100644
--- a/compiler/ccgutils.nim
+++ b/compiler/ccgutils.nim
@@ -93,7 +93,7 @@ proc getUniqueType*(key: PType): PType =
     # produced instead of ``NI``.
     result = key
   of  tyEmpty, tyNil, tyExpr, tyStmt, tyPointer, tyString,
-      tyCString, tyNone, tyBigNum, tyVoid:
+      tyCString, tyNone, tyVoid:
     result = gCanonicalTypes[k]
     if result == nil:
       gCanonicalTypes[k] = key
@@ -106,7 +106,7 @@ proc getUniqueType*(key: PType): PType =
   of tyDistinct:
     if key.deepCopy != nil: result = key
     else: result = getUniqueType(lastSon(key))
-  of tyGenericInst, tyOrdinal, tyMutable, tyConst, tyIter, tyStatic:
+  of tyGenericInst, tyOrdinal, tyStatic:
     result = getUniqueType(lastSon(key))
     #let obj = lastSon(key)
     #if obj.sym != nil and obj.sym.name.s == "TOption":
@@ -153,6 +153,7 @@ proc getUniqueType*(key: PType): PType =
     else:
       # ugh, we need the canon here:
       result = slowSearch(key, k)
+  of tyUnused, tyUnused0, tyUnused1, tyUnused2: internalError("getUniqueType")
 
 proc tableGetType*(tab: TIdTable, key: PType): RootRef =
   # returns nil if we need to declare this type
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 620ee4887..d80a68609 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -867,10 +867,11 @@ proc genMainProc(m: BModule) =
     MainProcsWithResult =
       MainProcs & "\treturn nim_program_result;$N"
 
-    NimMainBody =
-      "N_CDECL(void, NimMainInner)(void) {$N" &
+    NimMainInner = "N_CDECL(void, NimMainInner)(void) {$N" &
         "$1" &
-      "}$N$N" &
+      "}$N$N"
+      
+    NimMainProc =
       "N_CDECL(void, NimMain)(void) {$N" &
         "\tvoid (*volatile inner)();$N" &
         "\tPreMain();$N" &
@@ -879,6 +880,8 @@ proc genMainProc(m: BModule) =
         "\t(*inner)();$N" &
       "}$N$N"
 
+    NimMainBody = NimMainInner & NimMainProc
+
     PosixNimMain =
       "int cmdCount;$N" &
       "char** cmdLine;$N" &
@@ -906,7 +909,7 @@ proc genMainProc(m: BModule) =
       "                        LPSTR lpCmdLine, int nCmdShow) {$N" &
       MainProcsWithResult & "}$N$N"
 
-    WinNimDllMain = "N_LIB_EXPORT " & NimMainBody
+    WinNimDllMain = NimMainInner & "N_LIB_EXPORT " & NimMainProc
 
     WinCDllMain =
       "BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, $N" &
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index c220902ff..189a055c3 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -184,7 +184,7 @@ proc genRecComment(d: PDoc, n: PNode): Rope =
   if n == nil: return nil
   result = genComment(d, n).rope
   if result == nil:
-    if n.kind notin {nkEmpty..nkNilLit, nkEnumTy}:
+    if n.kind notin {nkEmpty..nkNilLit, nkEnumTy, nkTupleTy}:
       for i in countup(0, len(n)-1):
         result = genRecComment(d, n.sons[i])
         if result != nil: return
diff --git a/compiler/installer.ini b/compiler/installer.ini
index cb7b86427..5e4b3ddbc 100644
--- a/compiler/installer.ini
+++ b/compiler/installer.ini
@@ -41,8 +41,8 @@ Files: "config/nimdoc.tex.cfg"
 ; Files: "doc/*.cfg"
 ; Files: "doc/*.pdf"
 ; Files: "doc/*.ini"
-Files: "doc/overview.html"
-Start: "doc/overview.html"
+Files: "doc/html/overview.html"
+Start: "doc/html/overview.html"
 
 
 [Other]
@@ -63,6 +63,7 @@ Files: "icons/koch_icon.o"
 
 Files: "compiler"
 Files: "doc"
+Files: "doc/html"
 Files: "tools"
 Files: "web/website.ini"
 Files: "web/ticker.html"
@@ -89,12 +90,11 @@ Files: "bin/c2nim.exe"
 Files: "bin/nimgrep.exe"
 Files: "bin/nimsuggest.exe"
 Files: "bin/nimble.exe"
-Files: "bin/*.dll"
 
-Files: "dist/*.dll"
 Files: "koch.exe"
+Files: "finish.exe"
 ; Files: "dist/mingw"
-Files: "start.bat"
+Files: r"tools\start.bat"
 BinPath: r"bin;dist\mingw\bin;dist"
 
 ;           Section | dir | zipFile | size hint (in KB) | url | exe start menu entry
@@ -104,6 +104,10 @@ Download: r"Support DLLs|bin|nim_dlls.zip|479|http://nim-lang.org/download/dlls.
 Download: r"Aporia Text Editor|dist|aporia.zip|97997|http://nim-lang.org/download/aporia-0.4.0.zip|aporia-0.4.0\bin\aporia.exe"
 ; for now only NSIS supports optional downloads
 
+[WinBin]
+Files: "$NIMINSTDEPS/makelink.exe"
+Files: "$NIMINSTDEPS/*.dll"
+
 [UnixBin]
 Files: "bin/nim"
 
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index e7fe8cc27..891e68f77 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -138,7 +138,7 @@ proc declareGlobal(p: PProc; id: int; r: Rope) =
 
 const
   MappedToObject = {tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray,
-    tySet, tyBigNum, tyVarargs}
+    tySet, tyVarargs}
 
 proc mapType(typ: PType): TJSTypeKind =
   let t = skipTypes(typ, abstractInst)
@@ -151,15 +151,13 @@ proc mapType(typ: PType): TJSTypeKind =
   of tyPointer:
     # treat a tyPointer like a typed pointer to an array of bytes
     result = etyBaseIndex
-  of tyRange, tyDistinct, tyOrdinal, tyConst, tyMutable, tyIter, tyProxy:
-    result = mapType(t.sons[0])
+  of tyRange, tyDistinct, tyOrdinal, tyProxy: result = mapType(t.sons[0])
   of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyChar: result = etyInt
   of tyBool: result = etyBool
   of tyFloat..tyFloat128: result = etyFloat
   of tySet: result = etyObject # map a set to a table
   of tyString, tySequence: result = etySeq
-  of tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray, tyBigNum,
-     tyVarargs:
+  of tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray, tyVarargs:
     result = etyObject
   of tyNil: result = etyNull
   of tyGenericInst, tyGenericParam, tyGenericBody, tyGenericInvocation,
@@ -171,6 +169,7 @@ proc mapType(typ: PType): TJSTypeKind =
     else: result = etyNone
   of tyProc: result = etyProc
   of tyCString: result = etyString
+  of tyUnused, tyUnused0, tyUnused1, tyUnused2: internalError("mapType")
 
 proc mapType(p: PProc; typ: PType): TJSTypeKind =
   if p.target == targetPHP: result = etyObject
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index fd0aafccb..a44a1306c 100644
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -215,7 +215,7 @@ const
     errOrdinalTypeExpected: "ordinal type expected",
     errOrdinalOrFloatTypeExpected: "ordinal or float type expected",
     errOverOrUnderflow: "over- or underflow",
-    errCannotEvalXBecauseIncompletelyDefined: "cannot evalutate '$1' because type is not defined completely",
+    errCannotEvalXBecauseIncompletelyDefined: "cannot evaluate '$1' because type is not defined completely",
     errChrExpectsRange0_255: "\'chr\' expects an int in the range 0..255",
     errDynlibRequiresExportc: "\'dynlib\' requires \'exportc\'",
     errUndeclaredFieldX: "undeclared field: \'$1\'",
diff --git a/compiler/nim.nim b/compiler/nim.nim
index a58afd593..0afefa853 100644
--- a/compiler/nim.nim
+++ b/compiler/nim.nim
@@ -13,6 +13,11 @@ when defined(gcc) and defined(windows):
   else:
     {.link: "icons/nim_icon.o".}
 
+when defined(amd64) and defined(windows) and defined(vcc):
+  {.link: "icons/nim-amd64-windows-vcc.res" .}
+when defined(i386) and defined(windows) and defined(vcc):
+  {.link: "icons/nim-i386-windows-vcc.res" .}
+
 import
   commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
   extccomp, strutils, os, osproc, platform, main, parseopt, service,
diff --git a/compiler/nimfix/nimfix.nim b/compiler/nimfix/nimfix.nim
index 39436702f..b4007cdaf 100644
--- a/compiler/nimfix/nimfix.nim
+++ b/compiler/nimfix/nimfix.nim
@@ -73,7 +73,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
         of "auto": gStyleCheck = StyleCheck.Auto
         else: localError(gCmdLineInfo, errOnOrOffExpected)
       of "wholeproject": gOnlyMainfile = false
-      of "besteffort": msgs.gErrorMax = high(int) # dont stop after first error
+      of "besteffort": msgs.gErrorMax = high(int) # don't stop after first error
       else:
         processSwitch(pass, p)
     of cmdArgument:
diff --git a/compiler/parampatterns.nim b/compiler/parampatterns.nim
index f8f1f355c..c51d406ac 100644
--- a/compiler/parampatterns.nim
+++ b/compiler/parampatterns.nim
@@ -230,6 +230,8 @@ proc isAssignable*(owner: PSym, n: PNode; isUnsafeAddr=false): TAssignableResult
     # builtin slice keeps lvalue-ness:
     if getMagic(n) in {mArrGet, mSlice}:
       result = isAssignable(owner, n.sons[1], isUnsafeAddr)
+    elif n.typ != nil and n.typ.kind == tyVar:
+      result = arLValue
   of nkStmtList, nkStmtListExpr:
     if n.typ != nil:
       result = isAssignable(owner, n.lastSon, isUnsafeAddr)
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index a116a8afe..d06269156 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -289,8 +289,7 @@ proc lsub(n: PNode): int
 proc litAux(n: PNode, x: BiggestInt, size: int): string =
   proc skip(t: PType): PType =
     result = t
-    while result.kind in {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
-                          tyConst, tyMutable}:
+    while result.kind in {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal}:
       result = lastSon(result)
   if n.typ != nil and n.typ.skip.kind in {tyBool, tyEnum}:
     let enumfields = n.typ.skip.n
diff --git a/compiler/semasgn.nim b/compiler/semasgn.nim
index 2e925e386..c4116a814 100644
--- a/compiler/semasgn.nim
+++ b/compiler/semasgn.nim
@@ -221,14 +221,15 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
       body.add newAsgnStmt(x, call)
   of tyVarargs, tyOpenArray:
     localError(c.info, errGenerated, "cannot copy openArray")
-  of tyFromExpr, tyIter, tyProxy, tyBuiltInTypeClass, tyUserTypeClass,
+  of tyFromExpr, tyProxy, tyBuiltInTypeClass, tyUserTypeClass,
      tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot, tyAnything,
-     tyMutable, tyGenericParam, tyGenericBody, tyNil, tyExpr, tyStmt,
-     tyTypeDesc, tyGenericInvocation, tyBigNum, tyConst, tyForward:
+     tyGenericParam, tyGenericBody, tyNil, tyExpr, tyStmt,
+     tyTypeDesc, tyGenericInvocation, tyForward:
     internalError(c.info, "assignment requested for type: " & typeToString(t))
   of tyOrdinal, tyRange,
      tyGenericInst, tyFieldAccessor, tyStatic, tyVar:
     liftBodyAux(c, lastSon(t), body, x, y)
+  of tyUnused, tyUnused0, tyUnused1, tyUnused2: internalError("liftBodyAux")
 
 proc newProcType(info: TLineInfo; owner: PSym): PType =
   result = newType(tyProc, owner)
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 3037a6ecc..ca9b5effb 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -462,7 +462,7 @@ proc searchForBorrowProc(c: PContext, startScope: PScope, fn: PSym): PSym =
   call.add(newIdentNode(fn.name, fn.info))
   for i in 1.. <fn.typ.n.len:
     let param = fn.typ.n.sons[i]
-    let t = skipTypes(param.typ, abstractVar-{tyTypeDesc})
+    let t = skipTypes(param.typ, abstractVar-{tyTypeDesc, tyDistinct})
     if t.kind == tyDistinct or param.typ.kind == tyDistinct: hasDistinct = true
     var x: PType
     if param.typ.kind == tyVar:
diff --git a/compiler/semdestruct.nim b/compiler/semdestruct.nim
index 9ea581f3a..85d106056 100644
--- a/compiler/semdestruct.nim
+++ b/compiler/semdestruct.nim
@@ -124,7 +124,7 @@ proc instantiateDestructor(c: PContext, typ: PType): PType =
   # destructor that must be used for the varialbe.
   # The destructor is either user-defined or automatically
   # generated by the compiler in a member-wise fashion.
-  var t = skipTypes(typ, {tyConst, tyMutable}).skipGenericAlias
+  var t = typ.skipGenericAlias
   let typeHoldingUserDefinition = if t.kind == tyGenericInst: t.base else: t
 
   if typeHoldingUserDefinition.destructor != nil:
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 93d5ed1a2..1756e4d0e 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -136,8 +136,10 @@ proc isCastable(dst, src: PType): bool =
   #                       tyProc, tySet, tyEnum, tyBool, tyChar}
   if skipTypes(dst, abstractInst-{tyOpenArray}).kind == tyOpenArray:
     return false
-  var dstSize, srcSize: BiggestInt
+  if skipTypes(src, abstractInst-{tyTypeDesc}).kind == tyTypeDesc:
+    return false
 
+  var dstSize, srcSize: BiggestInt
   dstSize = computeSize(dst)
   srcSize = computeSize(src)
   if dstSize < 0:
@@ -693,6 +695,22 @@ proc semBracketedMacro(c: PContext; outer, inner: PNode; s: PSym;
   else: assert(false)
   return
 
+proc afterCallActions(c: PContext; n, orig: PNode, flags: TExprFlags): PNode =
+  result = n
+  let callee = result.sons[0].sym
+  case callee.kind
+  of skMacro: result = semMacroExpr(c, result, orig, callee, flags)
+  of skTemplate: result = semTemplateExpr(c, result, callee, flags)
+  else:
+    semFinishOperands(c, result)
+    activate(c, result)
+    fixAbstractType(c, result)
+    analyseIfAddressTakenInCall(c, result)
+    if callee.magic != mNone:
+      result = magicsAfterOverloadResolution(c, result, flags)
+  if c.inTypeClass == 0:
+    result = evalAtCompileTime(c, result)
+
 proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
   result = nil
   checkMinSonsLen(n, 1)
@@ -771,27 +789,11 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
       # See bug #904 of how to trigger it:
       return result
   #result = afterCallActions(c, result, nOrig, flags)
-  fixAbstractType(c, result)
-  analyseIfAddressTakenInCall(c, result)
-  if result.sons[0].kind == nkSym and result.sons[0].sym.magic != mNone:
-    result = magicsAfterOverloadResolution(c, result, flags)
-  result = evalAtCompileTime(c, result)
-
-proc afterCallActions(c: PContext; n, orig: PNode, flags: TExprFlags): PNode =
-  result = n
-  let callee = result.sons[0].sym
-  case callee.kind
-  of skMacro: result = semMacroExpr(c, result, orig, callee, flags)
-  of skTemplate: result = semTemplateExpr(c, result, callee, flags)
+  if result.sons[0].kind == nkSym:
+    result = afterCallActions(c, result, nOrig, flags)
   else:
-    semFinishOperands(c, result)
-    activate(c, result)
     fixAbstractType(c, result)
     analyseIfAddressTakenInCall(c, result)
-    if callee.magic != mNone:
-      result = magicsAfterOverloadResolution(c, result, flags)
-  if c.inTypeClass == 0:
-    result = evalAtCompileTime(c, result)
 
 proc semDirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
   # this seems to be a hotspot in the compiler!
diff --git a/compiler/seminst.nim b/compiler/seminst.nim
index d7cad6a2f..e1a65da74 100644
--- a/compiler/seminst.nim
+++ b/compiler/seminst.nim
@@ -58,7 +58,7 @@ iterator instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable): PSym
   for i, a in n.pairs:
     internalAssert a.kind == nkSym
     var q = a.sym
-    if q.typ.kind notin {tyTypeDesc, tyGenericParam, tyStatic, tyIter}+tyTypeClasses:
+    if q.typ.kind notin {tyTypeDesc, tyGenericParam, tyStatic}+tyTypeClasses:
       continue
     let symKind = if q.typ.kind == tyStatic: skConst else: skType
     var s = newSym(symKind, q.name, getCurrOwner(), q.info)
@@ -99,7 +99,8 @@ proc genericCacheGet(genericSym: PSym, entry: TInstantiation;
 
 proc freshGenSyms(n: PNode, owner, orig: PSym, symMap: var TIdTable) =
   # we need to create a fresh set of gensym'ed symbols:
-  if n.kind == nkSym and sfGenSym in n.sym.flags and n.sym.owner == orig:
+  if n.kind == nkSym and sfGenSym in n.sym.flags and
+      (n.sym.owner == orig or n.sym.owner.kind == skPackage):
     let s = n.sym
     var x = PSym(idTableGet(symMap, s))
     if x == nil:
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 806b00db6..cd90782d1 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -24,7 +24,7 @@ proc semTypeOf(c: PContext; n: PNode): PNode =
   result = newNodeI(nkTypeOfExpr, n.info)
   let typExpr = semExprWithType(c, n, {efInTypeof})
   result.add typExpr
-  result.typ = makeTypeDesc(c, typExpr.typ.skipTypes({tyTypeDesc, tyIter}))
+  result.typ = makeTypeDesc(c, typExpr.typ.skipTypes({tyTypeDesc}))
 
 type
   SemAsgnMode = enum asgnNormal, noOverloadedSubscript, noOverloadedAsgn
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index df9b3f69c..8aa8f15c8 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -204,17 +204,22 @@ proc listGcUnsafety(s: PSym; onlyWarning: bool; cycleCheck: var IntSet) =
   let u = s.gcUnsafetyReason
   if u != nil and not cycleCheck.containsOrIncl(u.id):
     let msgKind = if onlyWarning: warnGcUnsafe2 else: errGenerated
-    if u.kind in {skLet, skVar}:
+    case u.kind
+    of skLet, skVar:
       message(s.info, msgKind,
         ("'$#' is not GC-safe as it accesses '$#'" &
         " which is a global using GC'ed memory") % [s.name.s, u.name.s])
-    elif u.kind in routineKinds:
+    of routineKinds:
       # recursive call *always* produces only a warning so the full error
       # message is printed:
       listGcUnsafety(u, true, cycleCheck)
       message(s.info, msgKind,
         "'$#' is not GC-safe as it calls '$#'" %
         [s.name.s, u.name.s])
+    of skParam:
+      message(s.info, msgKind,
+        "'$#' is not GC-safe as it performs an indirect call via '$#'" %
+        [s.name.s, u.name.s])
     else:
       internalAssert u.kind == skUnknown
       message(u.info, msgKind,
@@ -721,7 +726,8 @@ proc track(tracked: PEffects, n: PNode) =
           # and it's not a recursive call:
           if not (a.kind == nkSym and a.sym == tracked.owner):
             markSideEffect(tracked, a)
-    for i in 1 .. <len(n): trackOperand(tracked, n.sons[i], paramType(op, i))
+    if a.kind != nkSym or a.sym.magic != mNBindSym:
+      for i in 1 .. <len(n): trackOperand(tracked, n.sons[i], paramType(op, i))
     if a.kind == nkSym and a.sym.magic in {mNew, mNewFinalize, mNewSeq}:
       # may not look like an assignment, but it is:
       let arg = n.sons[1]
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index b8dfede1f..15171874f 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -549,8 +549,6 @@ proc procTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
 
   of tyNil:
     result = f.allowsNil
-  of tyIter:
-    if tfIterator in f.flags: result = typeRel(c, f.base, a.base)
   else: discard
 
 proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} =
@@ -1021,11 +1019,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
       var fskip = skippedNone
       let aobj = x.skipToObject(askip)
       let fobj = genericBody.lastSon.skipToObject(fskip)
+      var depth = -1
       if fobj != nil and aobj != nil and askip == fskip:
-        let depth = isObjectSubtype(c, aobj, fobj, f)
-        if depth >= 0:
-          c.inheritancePenalty += depth
-          return if depth == 0: isGeneric else: isSubtype
+        depth = isObjectSubtype(c, aobj, fobj, f)
       result = typeRel(c, genericBody, x)
       if result != isNone:
         # see tests/generics/tgeneric3.nim for an example that triggers this
@@ -1047,6 +1043,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
           else:
             put(c, f.sons[i], x)
 
+      if depth >= 0:
+        c.inheritancePenalty += depth
+        # bug #4863: We still need to bind generic alias crap, so
+        # we cannot return immediately:
+        result = if depth == 0: isGeneric else: isSubtype
   of tyAnd:
     considerPreviousT:
       result = isEqual
@@ -1220,13 +1221,6 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
       else:
         result = isNone
 
-  of tyIter:
-    if a.kind == tyIter or
-      (a.kind == tyProc and tfIterator in a.flags):
-      result = typeRel(c, f.base, a.base)
-    else:
-      result = isNone
-
   of tyStmt:
     if aOrig != nil and tfOldSchoolExprStmt notin f.flags:
       put(c, f, aOrig)
@@ -1567,8 +1561,13 @@ proc paramTypesMatch*(m: var TCandidate, f, a: PType,
 
 
 proc setSon(father: PNode, at: int, son: PNode) =
-  if sonsLen(father) <= at: setLen(father.sons, at + 1)
+  let oldLen = father.len
+  if oldLen <= at:
+    setLen(father.sons, at + 1)
   father.sons[at] = son
+  # insert potential 'void' parameters:
+  #for i in oldLen ..< at:
+  #  father.sons[i] = newNodeIT(nkEmpty, son.info, getSysType(tyVoid))
 
 # we are allowed to modify the calling node in the 'prepare*' procs:
 proc prepareOperand(c: PContext; formal: PType; a: PNode): PNode =
@@ -1579,8 +1578,9 @@ proc prepareOperand(c: PContext; formal: PType; a: PNode): PNode =
   elif a.typ.isNil:
     # XXX This is unsound! 'formal' can differ from overloaded routine to
     # overloaded routine!
-    let flags = if formal.kind == tyIter: {efDetermineType, efWantIterator}
-                else: {efDetermineType, efAllowStmt}
+    let flags = {efDetermineType, efAllowStmt}
+                #if formal.kind == tyIter: {efDetermineType, efWantIterator}
+                #else: {efDetermineType, efAllowStmt}
                 #elif formal.kind == tyStmt: {efDetermineType, efWantStmt}
                 #else: {efDetermineType}
     result = c.semOperand(c, a, flags)
diff --git a/compiler/types.nim b/compiler/types.nim
index 3db0c4507..fc50449ec 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -51,18 +51,14 @@ const
   # TODO: Remove tyTypeDesc from each abstractX and (where necessary)
   # replace with typedescX
   abstractPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyDistinct, tyOrdinal,
-                   tyConst, tyMutable, tyTypeDesc}
-  abstractVar* = {tyVar, tyGenericInst, tyDistinct, tyOrdinal,
-                  tyConst, tyMutable, tyTypeDesc}
-  abstractRange* = {tyGenericInst, tyRange, tyDistinct, tyOrdinal,
-                    tyConst, tyMutable, tyTypeDesc}
-  abstractVarRange* = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
-                       tyConst, tyMutable, tyTypeDesc}
-  abstractInst* = {tyGenericInst, tyDistinct, tyConst, tyMutable, tyOrdinal,
                    tyTypeDesc}
+  abstractVar* = {tyVar, tyGenericInst, tyDistinct, tyOrdinal, tyTypeDesc}
+  abstractRange* = {tyGenericInst, tyRange, tyDistinct, tyOrdinal, tyTypeDesc}
+  abstractVarRange* = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
+                       tyTypeDesc}
+  abstractInst* = {tyGenericInst, tyDistinct, tyOrdinal, tyTypeDesc}
 
-  skipPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyConst, tyMutable,
-               tyTypeDesc}
+  skipPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyTypeDesc}
   # typedescX is used if we're sure tyTypeDesc should be included (or skipped)
   typedescPtrs* = abstractPtrs + {tyTypeDesc}
   typedescInst* = abstractInst + {tyTypeDesc}
@@ -116,8 +112,7 @@ proc isFloatLit*(t: PType): bool {.inline.} =
 proc isCompatibleToCString(a: PType): bool =
   if a.kind == tyArray:
     if (firstOrd(a.sons[0]) == 0) and
-        (skipTypes(a.sons[0], {tyRange, tyConst,
-                               tyMutable, tyGenericInst}).kind in
+        (skipTypes(a.sons[0], {tyRange, tyGenericInst}).kind in
             {tyInt..tyInt64, tyUInt..tyUInt64}) and
         (a.sons[1].kind == tyChar):
       result = true
@@ -151,13 +146,12 @@ proc isOrdinalType(t: PType): bool =
   const
     # caution: uint, uint64 are no ordinal types!
     baseKinds = {tyChar,tyInt..tyInt64,tyUInt8..tyUInt32,tyBool,tyEnum}
-    parentKinds = {tyRange, tyOrdinal, tyConst, tyMutable, tyGenericInst,
-                   tyDistinct}
+    parentKinds = {tyRange, tyOrdinal, tyGenericInst, tyDistinct}
   t.kind in baseKinds or (t.kind in parentKinds and isOrdinalType(t.sons[0]))
 
 proc enumHasHoles(t: PType): bool =
   var b = t
-  while b.kind in {tyConst, tyMutable, tyRange, tyGenericInst}: b = b.sons[0]
+  while b.kind in {tyRange, tyGenericInst}: b = b.sons[0]
   result = b.kind == tyEnum and tfEnumHasHoles in b.flags
 
 proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter,
@@ -275,7 +269,7 @@ proc analyseObjectWithTypeFieldAux(t: PType,
       if res == frHeader: result = frHeader
     if result == frNone:
       if isObjectWithTypeFieldPredicate(t): result = frHeader
-  of tyGenericInst, tyDistinct, tyConst, tyMutable:
+  of tyGenericInst, tyDistinct:
     result = analyseObjectWithTypeFieldAux(lastSon(t), marker)
   of tyArray, tyArrayConstr, tyTuple:
     for i in countup(0, sonsLen(t) - 1):
@@ -408,8 +402,8 @@ const
     "int", "int8", "int16", "int32", "int64",
     "float", "float32", "float64", "float128",
     "uint", "uint8", "uint16", "uint32", "uint64",
-    "bignum", "const ",
-    "!", "varargs[$1]", "iter[$1]", "Error Type",
+    "unused0", "unused1",
+    "unused2", "varargs[$1]", "unused", "Error Type",
     "BuiltInTypeClass", "UserTypeClass",
     "UserTypeClassInst", "CompositeTypeClass",
     "and", "or", "not", "any", "static", "TypeFromExpr", "FieldAccessor",
@@ -534,7 +528,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
         add(result, typeToString(t.sons[i]))
         if i < sonsLen(t) - 1: add(result, ", ")
       add(result, ')')
-  of tyPtr, tyRef, tyVar, tyMutable, tyConst:
+  of tyPtr, tyRef, tyVar:
     result = typeToStr[t.kind]
     if t.len >= 2:
       setLen(result, result.len-1)
@@ -572,7 +566,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
       addSep(prag)
       add(prag, "locks: " & $t.lockLevel)
     if len(prag) != 0: add(result, "{." & prag & ".}")
-  of tyVarargs, tyIter:
+  of tyVarargs:
     result = typeToStr[t.kind] % typeToString(t.sons[0])
   else:
     result = typeToStr[t.kind]
@@ -606,7 +600,7 @@ proc firstOrd(t: PType): BiggestInt =
     else:
       assert(t.n.sons[0].kind == nkSym)
       result = t.n.sons[0].sym.position
-  of tyGenericInst, tyDistinct, tyConst, tyMutable, tyTypeDesc, tyFieldAccessor:
+  of tyGenericInst, tyDistinct, tyTypeDesc, tyFieldAccessor:
     result = firstOrd(lastSon(t))
   of tyOrdinal:
     if t.len > 0: result = firstOrd(lastSon(t))
@@ -642,8 +636,7 @@ proc lastOrd(t: PType): BiggestInt =
   of tyEnum:
     assert(t.n.sons[sonsLen(t.n) - 1].kind == nkSym)
     result = t.n.sons[sonsLen(t.n) - 1].sym.position
-  of tyGenericInst, tyDistinct, tyConst, tyMutable,
-     tyTypeDesc, tyFieldAccessor:
+  of tyGenericInst, tyDistinct, tyTypeDesc, tyFieldAccessor:
     result = lastOrd(lastSon(t))
   of tyProxy: result = 0
   of tyOrdinal:
@@ -656,7 +649,7 @@ proc lastOrd(t: PType): BiggestInt =
 proc lengthOrd(t: PType): BiggestInt =
   case t.kind
   of tyInt64, tyInt32, tyInt: result = lastOrd(t)
-  of tyDistinct, tyConst, tyMutable: result = lengthOrd(t.sons[0])
+  of tyDistinct: result = lengthOrd(t.sons[0])
   else:
     let last = lastOrd t
     let first = firstOrd t
@@ -925,7 +918,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
 
   case a.kind
   of tyEmpty, tyChar, tyBool, tyNil, tyPointer, tyString, tyCString,
-     tyInt..tyBigNum, tyStmt, tyExpr, tyVoid:
+     tyInt..tyUInt64, tyStmt, tyExpr, tyVoid:
     result = sameFlags(a, b)
   of tyStatic, tyFromExpr:
     result = exprStructuralEquivalent(a.n, b.n) and sameFlags(a, b)
@@ -965,8 +958,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
       result = a.sym.position == b.sym.position
   of tyGenericInvocation, tyGenericBody, tySequence,
      tyOpenArray, tySet, tyRef, tyPtr, tyVar, tyArrayConstr,
-     tyArray, tyProc, tyConst, tyMutable, tyVarargs, tyIter,
-     tyOrdinal, tyTypeClasses, tyFieldAccessor:
+     tyArray, tyProc, tyVarargs, tyOrdinal, tyTypeClasses, tyFieldAccessor:
     cycleCheck()
     if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
     result = sameChildrenAux(a, b, c) and sameFlags(a, b)
@@ -980,6 +972,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
         sameValue(a.n.sons[1], b.n.sons[1])
   of tyGenericInst: discard
   of tyNone: result = false
+  of tyUnused, tyUnused0, tyUnused1, tyUnused2: internalError("sameFlags")
 
 proc sameBackendType*(x, y: PType): bool =
   var c = initSameTypeClosure()
@@ -1120,7 +1113,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
     result = t
   of tyNil:
     if kind != skConst: result = t
-  of tyString, tyBool, tyChar, tyEnum, tyInt..tyBigNum, tyCString, tyPointer:
+  of tyString, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCString, tyPointer:
     result = nil
   of tyOrdinal:
     if kind != skParam: result = t
@@ -1143,7 +1136,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
     else: result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
   of tyPtr:
     result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
-  of tyArrayConstr, tySet, tyConst, tyMutable, tyIter:
+  of tyArrayConstr, tySet:
     for i in countup(0, sonsLen(t) - 1):
       result = typeAllowedAux(marker, t.sons[i], kind, flags)
       if result != nil: break
@@ -1160,6 +1153,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
     # for now same as error node; we say it's a valid type as it should
     # prevent cascading errors:
     result = nil
+  of tyUnused, tyUnused0, tyUnused1, tyUnused2: internalError("typeAllowedAux")
 
 proc typeAllowed*(t: PType, kind: TSymKind): PType =
   # returns 'nil' on success and otherwise the part of the type that is
@@ -1250,8 +1244,7 @@ proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt =
     if typ.callConv == ccClosure: result = 2 * ptrSize
     else: result = ptrSize
     a = ptrSize
-  of tyNil, tyCString, tyString, tySequence, tyPtr, tyRef, tyVar, tyOpenArray,
-     tyBigNum:
+  of tyNil, tyCString, tyString, tySequence, tyPtr, tyRef, tyVar, tyOpenArray:
     let base = typ.lastSon
     if base == typ or (base.kind == tyTuple and base.size==szIllegalRecursion):
       result = szIllegalRecursion
@@ -1311,7 +1304,7 @@ proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt =
     if result < 0: return
     if a < maxAlign: a = maxAlign
     result = align(result, a)
-  of tyGenericInst, tyDistinct, tyGenericBody, tyMutable, tyConst, tyIter:
+  of tyGenericInst, tyDistinct, tyGenericBody:
     result = computeSizeAux(lastSon(typ), a)
   of tyTypeDesc:
     result = computeSizeAux(typ.base, a)
@@ -1374,7 +1367,7 @@ proc safeInheritanceDiff*(a, b: PType): int =
   if a.kind == tyError or b.kind == tyError:
     result = -1
   else:
-    result = inheritanceDiff(a, b)
+    result = inheritanceDiff(a.skipTypes(skipPtrs), b.skipTypes(skipPtrs))
 
 proc compatibleEffectsAux(se, re: PNode): bool =
   if re.isNil: return false
diff --git a/compiler/typesrenderer.nim b/compiler/typesrenderer.nim
index 438744b1c..e9c27ac9d 100644
--- a/compiler/typesrenderer.nim
+++ b/compiler/typesrenderer.nim
@@ -37,14 +37,20 @@ proc renderType(n: PNode): string =
   of nkIdent: result = n.ident.s
   of nkSym: result = typeToString(n.sym.typ)
   of nkVarTy:
-    assert len(n) == 1
-    result = renderType(n[0])
+    if n.len == 1:
+      result = renderType(n[0])
+    else:
+      result = "var"
   of nkRefTy:
-    assert len(n) == 1
-    result = "ref." & renderType(n[0])
+    if n.len == 1:
+      result = "ref." & renderType(n[0])
+    else:
+      result = "ref"
   of nkPtrTy:
-    assert len(n) == 1
-    result = "ptr." & renderType(n[0])
+    if n.len == 1:
+      result = "ptr." & renderType(n[0])
+    else:
+      result = "ptr"
   of nkProcTy:
     assert len(n) > 1
     let params = n[0]
diff --git a/compiler/vm.nim b/compiler/vm.nim
index efcc55c59..be522ced0 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -900,7 +900,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
         if newPc < pc: handleJmpBack()
         #echo "new pc ", newPc, " calling: ", prc.name.s
         var newFrame = PStackFrame(prc: prc, comesFrom: pc, next: tos)
-        newSeq(newFrame.slots, prc.offset)
+        newSeq(newFrame.slots, prc.offset+ord(isClosure))
         if not isEmptyType(prc.typ.sons[0]) or prc.kind == skMacro:
           putIntoReg(newFrame.slots[0], getNullValue(prc.typ.sons[0], prc.info))
         for i in 1 .. rc-1:
@@ -1242,7 +1242,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
 
       createStr regs[ra]
       regs[ra].node.strVal = opGorge(regs[rb].node.strVal,
-                                     regs[rc].node.strVal, regs[rd].node.strVal)
+                                     regs[rc].node.strVal, regs[rd].node.strVal,
+                                     c.debug[pc])
     of opcNError:
       stackTrace(c, tos, pc, errUser, regs[ra].node.strVal)
     of opcNWarning:
@@ -1421,7 +1422,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
                  else: regs[rc].node.strVal
       if k < 0 or k > ord(high(TSymKind)):
         internalError(c.debug[pc], "request to create symbol of invalid kind")
-      var sym = newSym(k.TSymKind, name.getIdent, c.module, c.debug[pc])
+      var sym = newSym(k.TSymKind, name.getIdent, c.module.owner, c.debug[pc])
       incl(sym.flags, sfGenSym)
       regs[ra].node = newSymNode(sym)
     of opcTypeTrait:
diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim
index b40ca1058..bd6908722 100644
--- a/compiler/vmdeps.nim
+++ b/compiler/vmdeps.nim
@@ -19,7 +19,8 @@ proc readOutput(p: Process): string =
     result.setLen(result.len - "\n".len)
   discard p.waitForExit
 
-proc opGorge*(cmd, input, cache: string): string =
+proc opGorge*(cmd, input, cache: string, info: TLineInfo): string =
+  let workingDir = parentDir(info.toFullPath)
   if cache.len > 0:# and optForceFullMake notin gGlobalOptions:
     let h = secureHash(cmd & "\t" & input & "\t" & cache)
     let filename = options.toGeneratedFile("gorge_" & $h, "txt")
@@ -30,7 +31,8 @@ proc opGorge*(cmd, input, cache: string): string =
       return
     var readSuccessful = false
     try:
-      var p = startProcess(cmd, options={poEvalCommand, poStderrToStdout})
+      var p = startProcess(cmd, workingDir,
+                           options={poEvalCommand, poStderrToStdout})
       if input.len != 0:
         p.inputStream.write(input)
         p.inputStream.close()
@@ -41,7 +43,8 @@ proc opGorge*(cmd, input, cache: string): string =
       if not readSuccessful: result = ""
   else:
     try:
-      var p = startProcess(cmd, options={poEvalCommand, poStderrToStdout})
+      var p = startProcess(cmd, workingDir,
+                           options={poEvalCommand, poStderrToStdout})
       if input.len != 0:
         p.inputStream.write(input)
         p.inputStream.close()
@@ -266,11 +269,7 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
   of tyUInt16: result = atomicType("uint16", mUint16)
   of tyUInt32: result = atomicType("uint32", mUint32)
   of tyUInt64: result = atomicType("uint64", mUint64)
-  of tyBigNum: result = atomicType("bignum", mNone)
-  of tyConst: result = mapTypeToBracket("const", mNone, t, info)
-  of tyMutable: result = mapTypeToBracket("mutable", mNone, t, info)
   of tyVarargs: result = mapTypeToBracket("varargs", mVarargs, t, info)
-  of tyIter: result = mapTypeToBracket("iter", mNone, t, info)
   of tyProxy: result = atomicType("error", mNone)
   of tyBuiltInTypeClass:
     result = mapTypeToBracket("builtinTypeClass", mNone, t, info)
@@ -292,6 +291,7 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
       result.add atomicType("static", mNone)
       if t.n != nil:
         result.add t.n.copyTree
+  of tyUnused, tyUnused0, tyUnused1, tyUnused2: internalError("mapTypeToAstX")
 
 proc opMapTypeToAst*(t: PType; info: TLineInfo): PNode =
   result = mapTypeToAstX(t, info, false, true)
diff --git a/contributors.txt b/contributors.txt
deleted file mode 100644
index d54ec844a..000000000
--- a/contributors.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Comex
-Eric Doughty-Papassideris
-Simon Hafner
-Keita Haga
-Grzegorz Adam Hankiewicz
-Philippe Lhoste
-Zahary Karadjov
-Mario Ray Mahardhika
-Alexander Mitchell-Robinson (Amrykid)
-Dominik Picheta
-Jonathan Plona
-Alexander Rødseth
diff --git a/doc/advopt.txt b/doc/advopt.txt
index 02e69c5b8..b8980fa9c 100644
--- a/doc/advopt.txt
+++ b/doc/advopt.txt
@@ -3,6 +3,7 @@ Advanced commands:
   //compileToCpp, cpp       compile project to C++ code
   //compileToOC, objc       compile project to Objective C code
   //js                      compile project to Javascript
+  //e                       run a Nimscript file
   //rst2html                convert a reStructuredText file to HTML
   //rst2tex                 convert a reStructuredText file to TeX
   //jsondoc                 extract the documentation to a json file
diff --git a/doc/astspec.txt b/doc/astspec.txt
index 35eb1727b..f430677af 100644
--- a/doc/astspec.txt
+++ b/doc/astspec.txt
@@ -1184,6 +1184,7 @@ Nim type                     Corresponding AST
 ``proc``                     ``nnkProcTy``
 ``iterator``                 ``nnkIteratorTy``
 ``object``                   ``nnkObjectTy``
+-------------                ---------------------------------------------
 
 Take special care when declaring types as ``proc``. The behavior is similar
 to ``Procedure declaration``, below, but does not treat ``nnkGenericParams``.
diff --git a/contributing.rst b/doc/contributing.rst
index 31f04a5e0..31f04a5e0 100644
--- a/contributing.rst
+++ b/doc/contributing.rst
diff --git a/doc/docs.txt b/doc/docs.rst
index 4484784ae..4484784ae 100644
--- a/doc/docs.txt
+++ b/doc/docs.rst
diff --git a/docstyle.rst b/doc/docstyle.rst
index d789b1df9..d789b1df9 100644
--- a/docstyle.rst
+++ b/doc/docstyle.rst
diff --git a/doc/gc.rst b/doc/gc.rst
index 1c8cb9122..bb0088617 100644
--- a/doc/gc.rst
+++ b/doc/gc.rst
@@ -19,8 +19,10 @@ This document describes how the GC works and how to tune it for
 
 The basic algorithm is *Deferred Reference Counting* with cycle detection.
 References on the stack are not counted for better performance (and easier C
-code generation). The GC **never** scans the whole heap but it may scan the
-delta-subgraph of the heap that changed since its last run.
+code generation). Cycle detection is currently done by a simple mark&sweep
+GC that has to scan the full (thread local heap). ``--gc:v2`` replaces this
+with an incremental mark and sweep. That it is not production ready yet,
+however.
 
 
 The GC is only triggered in a memory allocation operation. It is not triggered
@@ -34,17 +36,7 @@ Cycle collector
 ===============
 
 The cycle collector can be en-/disabled independently from the other parts of
-the GC with ``GC_enableMarkAndSweep`` and ``GC_disableMarkAndSweep``. The
-compiler analyses the types for their possibility to build cycles, but often
-it is necessary to help this analysis with the ``acyclic`` pragma (see
-`acyclic <manual.html#acyclic-pragma>`_ for further information).
-
-You can also use the ``acyclic`` pragma for data that is cyclic in reality and
-then break up the cycles explicitly with ``GC_addCycleRoot``. This can be a
-very valuable optimization; the Nim compiler itself relies on this
-optimization trick to improve performance. Note that ``GC_addCycleRoot`` is
-a quick operation; the root is only registered for the next run of the
-cycle collector.
+the GC with ``GC_enableMarkAndSweep`` and ``GC_disableMarkAndSweep``.
 
 
 Realtime support
@@ -55,19 +47,19 @@ defined via ``--define:useRealtimeGC`` (you can put this into your config
 file as well). With this switch the GC supports the following operations:
 
 .. code-block:: nim
-  proc GC_setMaxPause*(MaxPauseInUs: int)
+  proc GC_setMaxPause*(maxPauseInUs: int)
   proc GC_step*(us: int, strongAdvice = false, stackSize = -1)
 
-The unit of the parameters ``MaxPauseInUs`` and ``us`` is microseconds.
+The unit of the parameters ``maxPauseInUs`` and ``us`` is microseconds.
 
 These two procs are the two modus operandi of the realtime GC:
 
 (1) GC_SetMaxPause Mode
 
     You can call ``GC_SetMaxPause`` at program startup and then each triggered
-    GC run tries to not take longer than ``MaxPause`` time. However, it is
+    GC run tries to not take longer than ``maxPause`` time. However, it is
     possible (and common) that the work is nevertheless not evenly distributed
-    as each call to ``new`` can trigger the GC and thus take  ``MaxPause``
+    as each call to ``new`` can trigger the GC and thus take  ``maxPause``
     time.
 
 (2) GC_step Mode
@@ -86,8 +78,8 @@ These two procs are the two modus operandi of the realtime GC:
 These procs provide a "best effort" realtime guarantee; in particular the
 cycle collector is not aware of deadlines yet. Deactivate it to get more
 predictable realtime behaviour. Tests show that a 2ms max pause
-time will be met in almost all cases on modern CPUs unless the cycle collector
-is triggered.
+time will be met in almost all cases on modern CPUs (with the cycle collector
+disabled).
 
 
 Time measurement
diff --git a/doc/manual/exceptions.txt b/doc/manual/exceptions.txt
index d06c13df4..0f1240a4a 100644
--- a/doc/manual/exceptions.txt
+++ b/doc/manual/exceptions.txt
@@ -147,7 +147,7 @@ the ``raise`` statement is the only way to raise an exception.
 If no exception name is given, the current exception is `re-raised`:idx:. The
 `ReraiseError`:idx: exception is raised if there is no exception to
 re-raise. It follows that the ``raise`` statement *always* raises an
-exception (unless a raise hook has been provided).
+exception.
 
 
 Exception hierarchy
diff --git a/doc/overview.txt b/doc/overview.rst
index 5b41752ae..e01520d7c 100644
--- a/doc/overview.txt
+++ b/doc/overview.rst
@@ -5,5 +5,5 @@ Nim Documentation Overview
 :Author: Andreas Rumpf
 :Version: |nimversion|
 
-.. include:: ../doc/docs.txt
+.. include:: docs.rst
 
diff --git a/icons/koch-amd64-windows-vcc.res b/icons/koch-amd64-windows-vcc.res
new file mode 100644
index 000000000..90d7d1f7a
--- /dev/null
+++ b/icons/koch-amd64-windows-vcc.res
Binary files differdiff --git a/icons/koch-i386-windows-vcc.res b/icons/koch-i386-windows-vcc.res
new file mode 100644
index 000000000..90d7d1f7a
--- /dev/null
+++ b/icons/koch-i386-windows-vcc.res
Binary files differdiff --git a/icons/nim-amd64-windows-vcc.res b/icons/nim-amd64-windows-vcc.res
new file mode 100644
index 000000000..b2d8fc9eb
--- /dev/null
+++ b/icons/nim-amd64-windows-vcc.res
Binary files differdiff --git a/icons/nim-i386-windows-vcc.res b/icons/nim-i386-windows-vcc.res
new file mode 100644
index 000000000..b2d8fc9eb
--- /dev/null
+++ b/icons/nim-i386-windows-vcc.res
Binary files differdiff --git a/install.txt b/install.txt
index 833fbf0fb..6ab562b07 100644
--- a/install.txt
+++ b/install.txt
@@ -33,7 +33,8 @@ is more cumbersome then.
 To complete the installation you should also build Nim's tools like
 ``nimsuggest``, ``nimble`` or ``nimgrep`` via::
 
-  nim e install_tools.nims
+  nim c koch
+  koch tools
 
 Note that these tools should also end up in your ``PATH`` so adding
 ``$your_install_dir/bin/nim`` to your ``PATH`` is preferred over the symlink
@@ -53,10 +54,8 @@ or clang.
 Installation on Windows
 -----------------------
 
-Install Nim by downloading and running the ``nim_$version.exe`` file.
-As default, the ``GCC`` compiler is used that is bundled with this installer.
-You can change the configuration file ``config/nim.cfg`` to use
-another C compiler or change the path to GCC.
+Install Nim by downloading and unzipping the ``nim_$version.zip`` file.
+Run ``finish.exe`` to detect and setup your MingW environment.
 
 Currently, the following C compilers are supported under Windows:
 
@@ -85,4 +84,5 @@ Nimble is Nim's package manager. For the source based installations where you
 added Nim's ``bin`` directory to your ``$PATH`` the easiest way of installing
 Nimble is via::
 
-  nim e install_nimble.nims
+  nim c koch
+  koch nimble
diff --git a/install_nimble.nims b/install_nimble.nims
index 05024c046..6e929f499 100644
--- a/install_nimble.nims
+++ b/install_nimble.nims
@@ -3,6 +3,8 @@ import ospaths
 
 mode = ScriptMode.Verbose
 
+echo "This script is deprecated. Use 'koch nimble' instead."
+
 var id = 0
 while dirExists("nimble" & $id):
   inc id
@@ -20,4 +22,4 @@ try:
   mvFile "nimble" & $id & "/src/nimble".toExe, "bin/nimble".toExe
 except OSError:
   cpFile "nimble" & $id & "/src/nimble".toExe, "bin/nimble".toExe
-  
+
diff --git a/install_tools.nims b/install_tools.nims
index 6ecc545a5..f5f320f78 100644
--- a/install_tools.nims
+++ b/install_tools.nims
@@ -3,13 +3,18 @@ import ospaths
 
 mode = ScriptMode.Verbose
 
-let nimbleExe = "./bin/nimble".toExe
-selfExec "c --noNimblePath -p:compiler -o:" & nimbleExe &
-    " dist/nimble/src/nimble.nim"
+echo "This script is deprecated. Use 'koch tools' instead."
 
-let nimsugExe = "./bin/nimsuggest".toExe
-selfExec "c --noNimblePath -p:compiler -o:" & nimsugExe &
-    " dist/nimsuggest/nimsuggest.nim"
+if not dirExists"dist/nimble":
+  echo "[Error] This script only works for the tarball."
+else:
+  let nimbleExe = "./bin/nimble".toExe
+  selfExec "c --noNimblePath -p:compiler -o:" & nimbleExe &
+      " dist/nimble/src/nimble.nim"
 
-let nimgrepExe = "./bin/nimgrep".toExe
-selfExec "c -o:./bin/nimgrep tools/nimgrep.nim"
+  let nimsugExe = "./bin/nimsuggest".toExe
+  selfExec "c --noNimblePath -d:release -p:compiler -o:" & nimsugExe &
+      " dist/nimsuggest/nimsuggest.nim"
+
+  let nimgrepExe = "./bin/nimgrep".toExe
+  selfExec "c -d:release -o:" & nimgrepExe & " tools/nimgrep.nim"
diff --git a/koch.nim b/koch.nim
index 1e78abbca..a3f5fb3de 100644
--- a/koch.nim
+++ b/koch.nim
@@ -15,16 +15,16 @@ when defined(gcc) and defined(windows):
   else:
     {.link: "icons/koch_icon.o".}
 
+when defined(amd64) and defined(windows) and defined(vcc):
+  {.link: "icons/koch-amd64-windows-vcc.res" .}
+when defined(i386) and defined(windows) and defined(vcc):
+  {.link: "icons/koch-i386-windows-vcc.res" .}
+
 import
   os, strutils, parseopt, osproc, streams
 
 const VersionAsString = system.NimVersion #"0.10.2"
 
-when defined(withUpdate):
-  import httpclient
-when defined(haveZipLib):
-  import zipfiles
-
 const
   HelpText = """
 +-----------------------------------------------------------------+
@@ -40,7 +40,7 @@ Options:
   --help, -h               shows this help and quits
 Possible Commands:
   boot [options]           bootstraps with given command line options
-  install [bindir]         installs to given directory; Unix only!
+  distrohelper [bindir]    helper for distro packagers
   geninstall               generate ./install.sh; Unix only!
   testinstall              test tar.xz package; Unix only! Only for devs!
   clean                    cleans Nim project; removes generated files
@@ -52,10 +52,10 @@ Possible Commands:
   xz                       builds the installation XZ package
   nsis [options]           builds the NSIS Setup installer (for Windows)
   tests [options]          run the testsuite
-  update                   updates nim to the latest version from github
-                           (compile koch with -d:withUpdate to enable)
   temp options             creates a temporary compiler for testing
   winrelease               creates a release (for coredevs only)
+  nimble                   builds the Nimble tool
+  tools                    builds Nim related tools
 Boot options:
   -d:release               produce a release version of the compiler
   -d:tinyc                 include the Tiny C backend (not supported on Windows)
@@ -69,7 +69,10 @@ Web options:
                            build the official docs, use UA-48159761-1
 """
 
-proc exe(f: string): string = return addFileExt(f, ExeExt)
+proc exe(f: string): string =
+  result = addFileExt(f, ExeExt)
+  when defined(windows):
+    result = result.replace('/','\\')
 
 proc findNim(): string =
   var nim = "nim".exe
@@ -92,6 +95,9 @@ proc exec(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
   if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
   putEnv("PATH", prevPath)
 
+proc nimexec(cmd: string) =
+  exec findNim() & " " & cmd
+
 proc execCleanPath(cmd: string,
                    additionalPath = ""; errorcode: int = QuitFailure) =
   # simulate a poor man's virtual environment
@@ -145,13 +151,16 @@ proc copyExe(source, dest: string) =
   inclFilePermissions(dest, {fpUserExec})
 
 const
-  compileNimInst = "-d:useLibzipSrc tools/niminst/niminst"
+  compileNimInst = "tools/niminst/niminst"
 
 proc csource(args: string) =
-  exec("$4 cc $1 -r $3 --var:version=$2 --var:mingw=none csource --main:compiler/nim.nim compiler/installer.ini $1" %
-       [args, VersionAsString, compileNimInst, findNim()])
+  nimexec(("cc $1 -r $3 --var:version=$2 --var:mingw=none csource " &
+           "--main:compiler/nim.nim compiler/installer.ini $1") %
+       [args, VersionAsString, compileNimInst])
 
 proc bundleNimbleSrc() =
+  ## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We
+  ## always bundle the latest official release.
   if dirExists("dist/nimble/.git"):
     exec("git --git-dir dist/nimble/.git pull")
   else:
@@ -164,40 +173,81 @@ proc bundleNimbleExe() =
   bundleNimbleSrc()
   # now compile Nimble and copy it to $nim/bin for the installer.ini
   # to pick it up:
-  exec(findNim() & " c dist/nimble/src/nimble.nim")
+  nimexec("c dist/nimble/src/nimble.nim")
   copyExe("dist/nimble/src/nimble".exe, "bin/nimble".exe)
 
+proc buildNimble() =
+  ## buildNimble() builds Nimble for the building via "github". As such, we
+  ## choose the most recent commit of Nimble too.
+  var installDir = "dist/nimble"
+  if dirExists("dist/nimble/.git"):
+    exec("git --git-dir dist/nimble/.git pull")
+  else:
+    # if dist/nimble exist, but is not a git repo, don't mess with it:
+    if dirExists(installDir):
+      var id = 0
+      while dirExists("dist/nimble" & $id):
+        inc id
+      installDir = "dist/nimble" & $id
+    exec("git clone https://github.com/nim-lang/nimble.git " & installDir)
+  nimexec("c " & installDir / "src/nimble.nim")
+  copyExe(installDir / "src/nimble".exe, "bin/nimble".exe)
+
 proc bundleNimsuggest(buildExe: bool) =
   if dirExists("dist/nimsuggest/.git"):
     exec("git --git-dir dist/nimsuggest/.git pull")
   else:
     exec("git clone https://github.com/nim-lang/nimsuggest.git dist/nimsuggest")
   if buildExe:
-    exec(findNim() & " c --noNimblePath -p:compiler dist/nimsuggest/nimsuggest.nim")
+    nimexec("c --noNimblePath -d:release -p:compiler dist/nimsuggest/nimsuggest.nim")
     copyExe("dist/nimsuggest/nimsuggest".exe, "bin/nimsuggest".exe)
+    removeFile("dist/nimsuggest/nimsuggest".exe)
+
+proc bundleFinishExe() =
+  nimexec("c tools/finish.nim")
+  copyExe("tools/finish".exe, "finish".exe)
+  removeFile("tools/finish".exe)
 
 proc zip(args: string) =
   bundleNimbleSrc()
-  exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
-       [VersionAsString, compileNimInst, findNim()])
+  bundleNimsuggest(false)
+  bundleFinishExe()
+  nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
+       [VersionAsString, compileNimInst])
   exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
        ["tools/niminst/niminst".exe, VersionAsString])
 
 proc xz(args: string) =
   bundleNimbleSrc()
   bundleNimsuggest(false)
-  exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
-       [VersionAsString, compileNimInst, findNim()])
+  nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
+       [VersionAsString, compileNimInst])
   exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" %
        ["tools" / "niminst" / "niminst".exe, VersionAsString])
 
 proc buildTool(toolname, args: string) =
-  exec("$# cc $# $#" % [findNim(), args, toolname])
+  nimexec("cc $# $#" % [args, toolname])
   copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe)
 
+proc buildTools() =
+  if not dirExists"dist/nimble":
+    echo "[Error] 'koch tools' only works for the tarball."
+  else:
+    let nimbleExe = "bin/nimble".exe
+    nimexec "c --noNimblePath -p:compiler -o:" & nimbleExe &
+        " dist/nimble/src/nimble.nim"
+
+    let nimsugExe = "bin/nimsuggest".exe
+    nimexec "c --noNimblePath -p:compiler -d:release -o:" & nimsugExe &
+        " dist/nimsuggest/nimsuggest.nim"
+
+    let nimgrepExe = "bin/nimgrep".exe
+    nimexec "c -o:" & nimgrepExe & " tools/nimgrep.nim"
+
 proc nsis(args: string) =
   bundleNimbleExe()
   bundleNimsuggest(true)
+  bundleFinishExe()
   # make sure we have generated the niminst executables:
   buildTool("tools/niminst/niminst", args)
   #buildTool("tools/nimgrep", args)
@@ -208,21 +258,21 @@ proc nsis(args: string) =
         " nsis compiler/installer.ini") % [VersionAsString, $(sizeof(pointer)*8)])
 
 proc geninstall(args="") =
-  exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini $#" %
-       [findNim(), compileNimInst, VersionAsString, args])
+  nimexec("cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini $#" %
+       [compileNimInst, VersionAsString, args])
 
 proc install(args: string) =
   geninstall()
   exec("sh ./install.sh $#" % args)
 
 proc web(args: string) =
-  exec("$# js tools/dochack/dochack.nim" % findNim())
-  exec("$# cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
-       [findNim(), args, VersionAsString])
+  nimexec("js tools/dochack/dochack.nim")
+  nimexec("cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
+       [args, VersionAsString])
 
 proc website(args: string) =
-  exec("$# cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
-       [findNim(), args, VersionAsString])
+  nimexec("cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
+       [args, VersionAsString])
 
 proc pdf(args="") =
   exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
@@ -261,7 +311,7 @@ proc boot(args: string) =
   var finalDest = "bin" / "nim".exe
   # default to use the 'c' command:
   let bootOptions = if args.len == 0 or args.startsWith("-"): "c" else: ""
-  let smartNimcache = if "release" in args: "rnimcache" else: "dnimcache"
+  let smartNimcache = if "release" in args: "nimcache/release" else: "nimcache/debug"
 
   copyExe(findStartNim(), 0.thVersion)
   for i in 0..2:
@@ -312,7 +362,6 @@ proc removePattern(pattern: string) =
     removeFile(f)
 
 proc clean(args: string) =
-  if existsFile("koch.dat"): removeFile("koch.dat")
   removePattern("web/*.html")
   removePattern("doc/*.html")
   cleanAux(getCurrentDir())
@@ -321,83 +370,8 @@ proc clean(args: string) =
       echo "removing dir: ", path
       removeDir(path)
 
-# -------------- update -------------------------------------------------------
-
-when defined(withUpdate):
-  when defined(windows):
-    {.warning: "Windows users: Make sure to run 'koch update' in Bash.".}
-
-  proc update(args: string) =
-    when defined(windows):
-      echo("Windows users: Make sure to be running this in Bash. ",
-           "If you aren't, press CTRL+C now.")
-
-    var thisDir = getAppDir()
-    var git = findExe("git")
-    echo("Checking for git repo and git executable...")
-    if existsDir(thisDir & "/.git") and git != "":
-      echo("Git repo found!")
-      # use git to download latest source
-      echo("Checking for updates...")
-      discard startCmd(git & " fetch origin master")
-      var procs = startCmd(git & " diff origin/master master")
-      var errcode = procs.waitForExit()
-      var output = readLine(procs.outputStream)
-      echo(output)
-      if errcode == 0:
-        if output == "":
-          # No changes
-          echo("No update. Exiting...")
-          return
-        else:
-          echo("Fetching updates from repo...")
-          var pullout = execCmdEx(git & " pull origin master")
-          if pullout[1] != 0:
-            quit("An error has occurred.")
-          else:
-            if pullout[0].startsWith("Already up-to-date."):
-              quit("No new changes fetched from the repo. " &
-                   "Local branch must be ahead of it. Exiting...")
-      else:
-        quit("An error has occurred.")
-
-    else:
-      echo("No repo or executable found!")
-      when defined(haveZipLib):
-        echo("Falling back.. Downloading source code from repo...")
-        # use dom96's httpclient to download zip
-        downloadFile("https://github.com/Araq/Nim/zipball/master",
-                     thisDir / "update.zip")
-        try:
-          echo("Extracting source code from archive...")
-          var zip: TZipArchive
-          discard open(zip, thisDir & "/update.zip", fmRead)
-          extractAll(zip, thisDir & "/")
-        except:
-          quit("Error reading archive.")
-      else:
-        quit("No failback available. Exiting...")
-
-    echo("Starting update...")
-    boot(args)
-    echo("Update complete!")
-
 # -------------- builds a release ---------------------------------------------
 
-#[
-proc run7z(platform: string, patterns: varargs[string]) =
-  const tmpDir = "nim-" & VersionAsString
-  createDir tmpDir
-  try:
-    for pattern in patterns:
-      for f in walkFiles(pattern):
-        if "nimcache" notin f:
-          copyFile(f, tmpDir / f)
-    exec("7z a -tzip $1-$2.zip $1" % [tmpDir, platform])
-  finally:
-    removeDir tmpDir
-]#
-
 proc winRelease() =
   exec(r"call ci\nsis_build.bat " & VersionAsString)
 
@@ -408,11 +382,10 @@ template `|`(a, b): string = (if a.len > 0: a else: b)
 proc tests(args: string) =
   # we compile the tester with taintMode:on to have a basic
   # taint mode test :-)
-  let nimexe = findNim()
-  exec nimexe & " cc --taintMode:on tests/testament/tester"
+  nimexec "cc --taintMode:on tests/testament/tester"
   # Since tests take a long time (on my machine), and we want to defy Murhpys
   # law - lets make sure the compiler really is freshly compiled!
-  exec nimexe & " c --lib:lib -d:release --opt:speed compiler/nim.nim"
+  nimexec "c --lib:lib -d:release --opt:speed compiler/nim.nim"
   let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe)
   let success = tryExec tester & " " & (args|"all")
   if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"):
@@ -442,6 +415,7 @@ of cmdArgument:
   of "boot": boot(op.cmdLineRest)
   of "clean": clean(op.cmdLineRest)
   of "web": web(op.cmdLineRest)
+  of "doc", "docs": web("--onlyDocs " & op.cmdLineRest)
   of "json2": web("--json2 " & op.cmdLineRest)
   of "website": website(op.cmdLineRest & " --googleAnalytics:UA-48159761-1")
   of "web0":
@@ -453,15 +427,13 @@ of cmdArgument:
   of "xz": xz(op.cmdLineRest)
   of "nsis": nsis(op.cmdLineRest)
   of "geninstall": geninstall(op.cmdLineRest)
+  of "distrohelper": geninstall()
   of "install": install(op.cmdLineRest)
   of "testinstall": testUnixInstall()
   of "test", "tests": tests(op.cmdLineRest)
-  of "update":
-    when defined(withUpdate):
-      update(op.cmdLineRest)
-    else:
-      quit "this Koch has not been compiled with -d:withUpdate"
   of "temp": temp(op.cmdLineRest)
   of "winrelease": winRelease()
+  of "nimble": buildNimble()
+  of "tools": buildTools()
   else: showHelp()
 of cmdEnd: showHelp()
diff --git a/lib/arch/arch.nim b/lib/arch/arch.nim
index c8ae3da1c..0b3df3d3c 100644
--- a/lib/arch/arch.nim
+++ b/lib/arch/arch.nim
@@ -34,7 +34,7 @@ when defined(amd64):
     Reg* {.pure.} = enum
       AX, BX, CX, DX, SI, DI, BP, SP, IP, R8, R9, R10, R11, R12, R13, R14, R15, TOTAL
 
-elif defined(i386):
+elif defined(i386) or defined(nimdoc):
     # identical fastcall calling convention on all x86 OS
     type
       JmpBufReg* {.pure.} = enum
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 19452b4a8..d584b1ac5 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -78,7 +78,7 @@ type
     nnkBreakState
 
   NimNodeKinds* = set[NimNodeKind]
-  NimTypeKind* = enum
+  NimTypeKind* = enum  # some types are no longer used, see ast.nim
     ntyNone, ntyBool, ntyChar, ntyEmpty,
     ntyArrayConstr, ntyNil, ntyExpr, ntyStmt,
     ntyTypeDesc, ntyGenericInvocation, ntyGenericBody, ntyGenericInst,
@@ -90,9 +90,9 @@ type
     ntyInt8, ntyInt16, ntyInt32, ntyInt64,
     ntyFloat, ntyFloat32, ntyFloat64, ntyFloat128,
     ntyUInt, ntyUInt8, ntyUInt16, ntyUInt32, ntyUInt64,
-    ntyBigNum,
-    ntyConst, ntyMutable, ntyVarargs,
-    ntyIter,
+    ntyUnused0, ntyUnused1, ntyUnused2,
+    ntyVarargs,
+    ntyUnused,
     ntyError,
     ntyBuiltinTypeClass, ntyConcept, ntyConceptInst, ntyComposite,
     ntyAnd, ntyOr, ntyNot
@@ -890,6 +890,30 @@ proc boolVal*(n: NimNode): bool {.compileTime, noSideEffect.} =
   if n.kind == nnkIntLit: n.intVal != 0
   else: n == bindSym"true" # hacky solution for now
 
+macro expandMacros*(body: typed): untyped =
+  ## Expands one level of macro - useful for debugging.
+  ## Can be used to inspect what happens when a macro call is expanded,
+  ## without altering its result.
+  ##
+  ## For instance,
+  ##
+  ## .. code-block:: nim
+  ##   import future, macros
+  ##
+  ##   let
+  ##     x = 10
+  ##     y = 20
+  ##   expandMacros:
+  ##     dump(x + y)
+  ##
+  ## will actually dump `x + y`, but at the same time will print at
+  ## compile time the expansion of the ``dump`` macro, which in this
+  ## case is ``debugEcho ["x + y", " = ", x + y]``.
+  template inner(x: untyped): untyped = x
+
+  result = getAst(inner(body))
+  echo result.toStrLit
+
 when not defined(booting):
   template emit*(e: static[string]): untyped {.deprecated.} =
     ## accepts a single string argument and treats it as nim code
diff --git a/lib/impure/nre.nim b/lib/impure/nre.nim
index 557bb0549..626c3fd6b 100644
--- a/lib/impure/nre.nim
+++ b/lib/impure/nre.nim
@@ -431,8 +431,12 @@ proc initRegex(pattern: string, flags: int, study = true): Regex =
     raise SyntaxError(msg: $errorMsg, pos: errOffset, pattern: pattern)
 
   if study:
-    # XXX investigate JIT
-    result.pcreExtra = pcre.study(result.pcreObj, 0x0, addr errorMsg)
+    var options: cint = 0
+    var hasJit: cint
+    if pcre.config(pcre.CONFIG_JIT, addr hasJit) == 0:
+      if hasJit == 1'i32:
+        options = pcre.STUDY_JIT_COMPILE
+    result.pcreExtra = pcre.study(result.pcreObj, options, addr errorMsg)
     if errorMsg != nil:
       raise StudyError(msg: $errorMsg)
 
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index bd86bcdcf..f7f7c5b25 100644
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -87,7 +87,12 @@ proc re*(s: string, flags = {reExtended, reStudy}): Regex =
   result.h = rawCompile(s, cast[cint](flags - {reStudy}))
   if reStudy in flags:
     var msg: cstring
-    result.e = pcre.study(result.h, 0, addr msg)
+    var options: cint = 0
+    var hasJit: cint
+    if pcre.config(pcre.CONFIG_JIT, addr hasJit) == 0:
+      if hasJit == 1'i32:
+        options = pcre.STUDY_JIT_COMPILE
+    result.e = pcre.study(result.h, options, addr msg)
     if not isNil(msg): raiseInvalidRegex($msg)
 
 proc matchOrFind(s: string, pattern: Regex, matches: var openArray[string],
@@ -214,7 +219,7 @@ proc find*(s: string, pattern: Regex, start = 0): int =
   var
     rtarray = initRtArray[cint](3)
     rawMatches = rtarray.getRawData
-    res = pcre.exec(pattern.h, nil, s, len(s).cint, start.cint, 0'i32,
+    res = pcre.exec(pattern.h, pattern.e, s, len(s).cint, start.cint, 0'i32,
       cast[ptr cint](rawMatches), 3)
   if res < 0'i32: return res
   return rawMatches[0]
diff --git a/lib/js/jsconsole.nim b/lib/js/jsconsole.nim
new file mode 100644
index 000000000..d9ced95f0
--- /dev/null
+++ b/lib/js/jsconsole.nim
@@ -0,0 +1,44 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Wrapper for the `console` object for the `JavaScript backend
+## <backends.html#the-javascript-target>`_.
+
+when not defined(js) and not defined(Nimdoc):
+  {.error: "This module only works on the JavaScript platform".}
+
+import macros
+
+type Console* {.importc.} = ref object of RootObj
+
+proc convertToConsoleLoggable*[T](v: T): RootRef {.importcpp: "#".}
+template convertToConsoleLoggable*(v: string): RootRef = cast[RootRef](cstring(v))
+
+proc logImpl(console: Console) {.importcpp: "log", varargs.}
+proc debugImpl(console: Console) {.importcpp: "debug", varargs.}
+proc infoImpl(console: Console) {.importcpp: "info", varargs.}
+proc errorImpl(console: Console) {.importcpp: "error", varargs.}
+
+proc makeConsoleCall(console: NimNode, procName: NimNode, args: NimNode): NimNode =
+  result = newCall(procName, console)
+  for c in args: result.add(c)
+
+macro log*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]): untyped =
+  makeConsoleCall(console, bindSym "logImpl", args)
+
+macro debug*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]): untyped =
+  makeConsoleCall(console, bindSym "debugImpl", args)
+
+macro info*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]): untyped =
+  makeConsoleCall(console, bindSym "infoImpl", args)
+
+macro error*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]): untyped =
+  makeConsoleCall(console, bindSym "errorImpl", args)
+
+var console* {.importc, nodecl.}: Console
\ No newline at end of file
diff --git a/lib/packages/docutils/highlite.nim b/lib/packages/docutils/highlite.nim
index 9de25f82b..06b90768c 100644
--- a/lib/packages/docutils/highlite.nim
+++ b/lib/packages/docutils/highlite.nim
@@ -242,14 +242,17 @@ proc nimNextToken(g: var GeneralTokenizer) =
       inc(pos)
       case g.buf[pos]
       of 'b', 'B':
+        g.kind = gtBinNumber
         inc(pos)
         while g.buf[pos] in binChars: inc(pos)
         pos = nimNumberPostfix(g, pos)
       of 'x', 'X':
+        g.kind = gtHexNumber
         inc(pos)
         while g.buf[pos] in hexChars: inc(pos)
         pos = nimNumberPostfix(g, pos)
       of 'o', 'O':
+        g.kind = gtOctNumber
         inc(pos)
         while g.buf[pos] in octChars: inc(pos)
         pos = nimNumberPostfix(g, pos)
@@ -700,8 +703,8 @@ proc yamlNextToken(g: var GeneralTokenizer) =
       g.state = gtLongStringLit
   elif g.state == gtLongStringLit:
     # beware, this is the only token where we actually have to parse
-    # indentation. 
-    
+    # indentation.
+
     g.kind = gtLongStringLit
     # first, we have to find the parent indentation of the block scalar, so that
     # we know when to stop
@@ -738,20 +741,20 @@ proc yamlNextToken(g: var GeneralTokenizer) =
     # because lookbehind was at newline char when calculating indentation, we're
     # off by one. fix that. top level's parent will have indentation of -1.
     let parentIndentation = indentation - 1
-    
+
     # find first content
     while g.buf[pos] in {' ', '\x0A', '\x0D'}:
       if g.buf[pos] == ' ': inc(indentation)
       else: indentation = 0
       inc(pos)
     var minIndentation = indentation
-    
+
     # for stupid edge cases, we must check whether an explicit indentation depth
     # is given at the header.
     while g.buf[headerStart] in {'>', '|', '+', '-'}: inc(headerStart)
     if g.buf[headerStart] in {'0'..'9'}:
       minIndentation = min(minIndentation, ord(g.buf[headerStart]) - ord('0'))
-    
+
     # process content lines
     while indentation > parentIndentation and g.buf[pos] != '\0':
       if (indentation < minIndentation and g.buf[pos] == '#') or
@@ -766,7 +769,7 @@ proc yamlNextToken(g: var GeneralTokenizer) =
         if g.buf[pos] == ' ': inc(indentation)
         else: indentation = 0
         inc(pos)
-    
+
     g.state = gtOther
   elif g.state == gtOther:
     # gtOther means 'inside YAML document'
diff --git a/lib/posix/kqueue.nim b/lib/posix/kqueue.nim
index 5c67d621e..19d661490 100644
--- a/lib/posix/kqueue.nim
+++ b/lib/posix/kqueue.nim
@@ -123,7 +123,7 @@ when defined(macosx) or defined(freebsd):
     NOTE_USECONDS*   = 0x00000004'u32 ## data is microseconds
     NOTE_NSECONDS*   = 0x00000008'u32 ## data is nanoseconds
 else:
-  # NetBSD and OpenBSD doesnt support NOTE_{TIME} constants, but
+  # NetBSD and OpenBSD doesn't support NOTE_{TIME} constants, but
   # support EVFILT_TIMER with granularity of milliseconds.
   const
     NOTE_MSECONDS*   = 0x00000000'u32
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index 8336da1fb..8c4a0e41d 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -132,7 +132,7 @@ export Port, SocketFlag
 ##        # Handle exception
 ##
 ## Unfortunately the semantics of the try statement may not always be correct,
-## and occassionally the compilation may fail altogether.
+## and occasionally the compilation may fail altogether.
 ## As such it is better to use the former style when possible.
 ##
 ## Discarding futures
@@ -1055,7 +1055,7 @@ else:
         # so that exceptions can be raised from `send(...)` and
         # `recv(...)` routines.
 
-        if EvRead in info.events:
+        if EvRead in info.events or info.events == {EvError}:
           # Callback may add items to ``data.readCBs`` which causes issues if
           # we are iterating over ``data.readCBs`` at the same time. We therefore
           # make a copy to iterate over.
@@ -1066,7 +1066,7 @@ else:
               # Callback wants to be called again.
               data.readCBs.add(cb)
 
-        if EvWrite in info.events:
+        if EvWrite in info.events or info.events == {EvError}:
           let currentCBs = data.writeCBs
           data.writeCBs = @[]
           for cb in currentCBs:
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
index f458b7636..45a148fbf 100644
--- a/lib/pure/collections/sequtils.nim
+++ b/lib/pure/collections/sequtils.nim
@@ -228,7 +228,7 @@ proc apply*[T](data: var seq[T], op: proc (x: var T) {.closure.})
   ##   var a = @["1", "2", "3", "4"]
   ##   echo repr(a)
   ##   # --> ["1", "2", "3", "4"]
-  ##   map(a, proc(x: var string) = x &= "42")
+  ##   apply(a, proc(x: var string) = x &= "42")
   ##   echo repr(a)
   ##   # --> ["142", "242", "342", "442"]
   ##
@@ -247,7 +247,7 @@ proc apply*[T](data: var seq[T], op: proc (x: T): T {.closure.})
   ##   var a = @["1", "2", "3", "4"]
   ##   echo repr(a)
   ##   # --> ["1", "2", "3", "4"]
-  ##   map(a, proc(x: string): string = x & "42")
+  ##   apply(a, proc(x: string): string = x & "42")
   ##   echo repr(a)
   ##   # --> ["142", "242", "342", "442"]
   ##
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 9fa8f5263..fe75f9a58 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -118,7 +118,11 @@ template dataLen(t): untyped = len(t.data)
 
 include tableimpl
 
-proc clear*[A, B](t: var Table[A, B] | TableRef[A, B]) =
+proc clear*[A, B](t: var Table[A, B]) =
+  ## Resets the table so that it is empty.
+  clearImpl()
+
+proc clear*[A, B](t: TableRef[A, B]) =
   ## Resets the table so that it is empty.
   clearImpl()
 
@@ -334,7 +338,7 @@ proc hasKey*[A, B](t: TableRef[A, B], key: A): bool =
   ## returns true iff `key` is in the table `t`.
   result = t[].hasKey(key)
 
-template equalsImpl(t) =
+template equalsImpl(s, t: typed): typed =
   if s.counter == t.counter:
     # different insertion orders mean different 'data' seqs, so we have
     # to use the slow route here:
@@ -344,7 +348,9 @@ template equalsImpl(t) =
     return true
 
 proc `==`*[A, B](s, t: Table[A, B]): bool =
-  equalsImpl(t)
+  ## The `==` operator for hash tables. Returns ``true`` iff the content of both
+  ## tables contains the same key-value pairs. Insert order does not matter.
+  equalsImpl(s, t)
 
 proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): Table[C, B] =
   ## Index the collection with the proc provided.
@@ -432,9 +438,12 @@ proc `$`*[A, B](t: TableRef[A, B]): string =
   dollarImpl()
 
 proc `==`*[A, B](s, t: TableRef[A, B]): bool =
+  ## The `==` operator for hash tables. Returns ``true`` iff either both tables 
+  ## are ``nil`` or none is ``nil`` and the content of both tables contains the
+  ## same key-value pairs. Insert order does not matter.
   if isNil(s): result = isNil(t)
   elif isNil(t): result = false
-  else: equalsImpl(t[])
+  else: equalsImpl(s[], t[])
 
 proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): TableRef[C, B] =
   ## Index the collection with the proc provided.
@@ -460,12 +469,16 @@ proc len*[A, B](t: OrderedTable[A, B]): int {.inline.} =
   ## returns the number of keys in `t`.
   result = t.counter
 
-proc clear*[A, B](t: var OrderedTable[A, B] | OrderedTableRef[A, B]) =
+proc clear*[A, B](t: var OrderedTable[A, B]) =
   ## Resets the table so that it is empty.
   clearImpl()
   t.first = -1
   t.last = -1
 
+proc clear*[A, B](t: var OrderedTableRef[A, B]) =
+  ## Resets the table so that is is empty.
+  clear(t[])
+
 template forAllOrderedPairs(yieldStmt: untyped) {.oldimmediate, dirty.} =
   var h = t.first
   while h >= 0:
@@ -602,6 +615,15 @@ proc `$`*[A, B](t: OrderedTable[A, B]): string =
   ## The `$` operator for ordered hash tables.
   dollarImpl()
 
+proc `==`*[A, B](s, t: OrderedTable[A, B]): bool =
+  ## The `==` operator for ordered hash tables. Both the content and the order
+  ## must be equal for this to return ``true``.
+  if s.counter == t.counter:
+    forAllOrderedPairs:
+      if s.data[h] != t.data[h]: return false
+    result = true
+  else: result = false
+
 proc sort*[A, B](t: var OrderedTable[A, B],
                  cmp: proc (x,y: (A, B)): int) =
   ## sorts `t` according to `cmp`. This modifies the internal list
@@ -745,6 +767,11 @@ proc `$`*[A, B](t: OrderedTableRef[A, B]): string =
   ## The `$` operator for ordered hash tables.
   dollarImpl()
 
+proc `==`*[A, B](s, t: OrderedTableRef[A, B]): bool =
+  ## The `==` operator for ordered hash tables. Both the content and the order
+  ## must be equal for this to return ``true``.
+  result = s[] == t[]
+
 proc sort*[A, B](t: OrderedTableRef[A, B],
                  cmp: proc (x,y: (A, B)): int) =
   ## sorts `t` according to `cmp`. This modifies the internal list
@@ -912,6 +939,11 @@ proc `$`*[A](t: CountTable[A]): string =
   ## The `$` operator for count tables.
   dollarImpl()
 
+proc `==`*[A](s, t: CountTable[A]): bool =
+  ## The `==` operator for count tables. Returns ``true`` iff both tables
+  ## contain the same keys with the same count. Insert order does not matter.
+  equalsImpl(s, t)
+
 proc inc*[A](t: var CountTable[A], key: A, val = 1) =
   ## increments `t[key]` by `val`.
   var index = rawGet(t, key)
@@ -1036,6 +1068,11 @@ proc `$`*[A](t: CountTableRef[A]): string =
   ## The `$` operator for count tables.
   dollarImpl()
 
+proc `==`*[A](s, t: CountTableRef[A]): bool =
+  ## The `==` operator for count tables. Returns ``true`` iff both tables
+  ## contain the same keys with the same count. Insert order does not matter.
+  result = s[] == t[]
+
 proc inc*[A](t: CountTableRef[A], key: A, val = 1) =
   ## increments `t[key]` by `val`.
   t[].inc(key, val)
diff --git a/lib/pure/future.nim b/lib/pure/future.nim
index 67975cfcb..2a6d29933 100644
--- a/lib/pure/future.nim
+++ b/lib/pure/future.nim
@@ -177,3 +177,24 @@ macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped =
               newIdentNode("@"),
               newNimNode(nnkBracket))),
           result))))
+
+
+macro dump*(x: typed): untyped =
+  ## Dumps the content of an expression, useful for debugging.
+  ## It accepts any expression and prints a textual representation
+  ## of the tree representing the expression - as it would appear in
+  ## source code - together with the value of the expression.
+  ##
+  ## As an example,
+  ##
+  ## .. code-block:: nim
+  ##   let
+  ##     x = 10
+  ##     y = 20
+  ##   dump(x + y)
+  ##
+  ## will print ``x + y = 30``.
+  let s = x.toStrLit
+  let r = quote do:
+    debugEcho `s`, " = ", `x`
+  return r
\ No newline at end of file
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index 4404a9426..c56d13b57 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -18,14 +18,14 @@
 ##
 ## .. code-block:: Nim
 ##   var client = newHttpClient()
-##   echo(getContent("http://google.com"))
+##   echo client.getContent("http://google.com")
 ##
 ## The same action can also be performed asynchronously, simply use the
 ## ``AsyncHttpClient``:
 ##
 ## .. code-block:: Nim
 ##   var client = newAsyncHttpClient()
-##   echo(await getContent("http://google.com"))
+##   echo await client.getContent("http://google.com")
 ##
 ## The functionality implemented by ``HttpClient`` and ``AsyncHttpClient``
 ## is the same, so you can use whichever one suits you best in the examples
@@ -50,6 +50,20 @@
 ##
 ##   echo client.postContent("http://validator.w3.org/check", multipart=data)
 ##
+## You can also make post requests with custom headers. 
+## This example sets ``Content-Type`` to ``application/json``
+## and uses a json object for the body
+##
+## .. code-block:: Nim
+##   import httpclient, json
+##   
+##   let client = newHttpClient()
+##   client.headers = newHttpHeaders({ "Content-Type": "application/json" })
+##   let body = %*{
+##       "data": "some text"
+##   }
+##   echo client.request("http://some.api", httpMethod = HttpPost, body = $body)
+##
 ## Progress reporting
 ## ==================
 ##
@@ -432,7 +446,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
 
 
   # get the socket ready. If we are connecting through a proxy to SSL,
-  # send the appropiate CONNECT header. If not, simply connect to the proper
+  # send the appropriate CONNECT header. If not, simply connect to the proper
   # host (which may still be the proxy, for normal HTTP)
   if proxy != nil and hostUrl.scheme == "https":
     when defined(ssl):
@@ -736,7 +750,7 @@ proc newHttpClient*(userAgent = defUserAgent,
   ## ``proxy`` specifies an HTTP proxy to use for this HTTP client's
   ## connections.
   ##
-  ## ``timeout`` specifies the number of miliseconds to allow before a
+  ## ``timeout`` specifies the number of milliseconds to allow before a
   ## ``TimeoutError`` is raised.
   new result
   result.headers = newHttpHeaders()
@@ -944,8 +958,10 @@ proc parseResponse(client: HttpClient | AsyncHttpClient,
 proc newConnection(client: HttpClient | AsyncHttpClient,
                    url: Uri) {.multisync.} =
   if client.currentURL.hostname != url.hostname or
-      client.currentURL.scheme != url.scheme:
-    if client.connected: client.close()
+      client.currentURL.scheme != url.scheme or
+      client.currentURL.port != url.port:
+    if client.connected:
+      client.close()
 
     when client is HttpClient:
       client.socket = newSocket()
diff --git a/lib/pure/ioselectors.nim b/lib/pure/ioselectors.nim
index adb3497ac..744bdbaa1 100644
--- a/lib/pure/ioselectors.nim
+++ b/lib/pure/ioselectors.nim
@@ -52,13 +52,13 @@ when defined(nimdoc):
       Vnode,       ## BSD specific file change happens
       User,        ## User event is raised
       Error,       ## Error happens while waiting, for descriptor
-      VnodeWrite,  ## NOTE_WRITE (BSD specific, write to file occured)
-      VnodeDelete, ## NOTE_DELETE (BSD specific, unlink of file occured)
+      VnodeWrite,  ## NOTE_WRITE (BSD specific, write to file occurred)
+      VnodeDelete, ## NOTE_DELETE (BSD specific, unlink of file occurred)
       VnodeExtend, ## NOTE_EXTEND (BSD specific, file extended)
       VnodeAttrib, ## NOTE_ATTRIB (BSD specific, file attributes changed)
       VnodeLink,   ## NOTE_LINK (BSD specific, file link count changed)
       VnodeRename, ## NOTE_RENAME (BSD specific, file renamed)
-      VnodeRevoke  ## NOTE_REVOKE (BSD specific, file revoke occured)
+      VnodeRevoke  ## NOTE_REVOKE (BSD specific, file revoke occurred)
 
     ReadyKey*[T] = object
       ## An object which holds result for descriptor
@@ -140,7 +140,7 @@ when defined(nimdoc):
 
   proc flush*[T](s: Selector[T]) =
     ## Flushes all changes was made to kernel pool/queue.
-    ## This function is usefull only for BSD and MacOS, because
+    ## This function is useful only for BSD and MacOS, because
     ## kqueue supports bulk changes to be made.
     ## On Linux/Windows and other Posix compatible operation systems,
     ## ``flush`` is alias for `discard`.
diff --git a/lib/pure/ioselects/ioselectors_kqueue.nim b/lib/pure/ioselects/ioselectors_kqueue.nim
index cdaeeae26..3c0cf4e90 100644
--- a/lib/pure/ioselects/ioselectors_kqueue.nim
+++ b/lib/pure/ioselects/ioselectors_kqueue.nim
@@ -26,8 +26,8 @@ when defined(macosx) or defined(freebsd):
     const MAX_DESCRIPTORS_ID = 29 # KERN_MAXFILESPERPROC (MacOS)
   else:
     const MAX_DESCRIPTORS_ID = 27 # KERN_MAXFILESPERPROC (FreeBSD)
-  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr int,
-              newp: pointer, newplen: int): cint
+  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
+              newp: pointer, newplen: csize): cint
        {.importc: "sysctl",header: """#include <sys/types.h>
                                       #include <sys/sysctl.h>"""}
 elif defined(netbsd) or defined(openbsd):
@@ -35,8 +35,8 @@ elif defined(netbsd) or defined(openbsd):
   # KERN_MAXFILES, because KERN_MAXFILES is always bigger,
   # than KERN_MAXFILESPERPROC.
   const MAX_DESCRIPTORS_ID = 7 # KERN_MAXFILES
-  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr int,
-              newp: pointer, newplen: int): cint
+  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
+              newp: pointer, newplen: csize): cint
        {.importc: "sysctl",header: """#include <sys/param.h>
                                       #include <sys/sysctl.h>"""}
 
@@ -72,7 +72,7 @@ type SelectEvent* = ptr SelectEventImpl
 
 proc newSelector*[T](): Selector[T] =
   var maxFD = 0.cint
-  var size = sizeof(cint)
+  var size = csize(sizeof(cint))
   var namearr = [1.cint, MAX_DESCRIPTORS_ID.cint]
   # Obtain maximum number of file descriptors for process
   if sysctl(addr(namearr[0]), 2, cast[pointer](addr maxFD), addr size,
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index cdbe170cc..001d3d250 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -50,6 +50,8 @@ proc c_getenv(env: cstring): cstring {.
   importc: "getenv", header: "<stdlib.h>".}
 proc c_putenv(env: cstring): cint {.
   importc: "putenv", header: "<stdlib.h>".}
+proc c_free(p: pointer) {.
+  importc: "free", header: "<stdlib.h>".}
 
 var errno {.importc, header: "<errno.h>".}: cint
 
@@ -303,24 +305,47 @@ proc fileNewer*(a, b: string): bool {.rtl, extern: "nos$1".} =
 
 proc getCurrentDir*(): string {.rtl, extern: "nos$1", tags: [].} =
   ## Returns the `current working directory`:idx:.
-  const bufsize = 512 # should be enough
   when defined(windows):
+    var bufsize = MAX_PATH.int32
     when useWinUnicode:
       var res = newWideCString("", bufsize)
-      var L = getCurrentDirectoryW(bufsize, res)
-      if L == 0'i32: raiseOSError(osLastError())
-      result = res$L
+      while true:
+        var L = getCurrentDirectoryW(bufsize, res)
+        if L == 0'i32:
+          raiseOSError(osLastError())
+        elif L > bufsize:
+          res = newWideCString("", L)
+          bufsize = L
+        else:
+          result = res$L
+          break
     else:
       result = newString(bufsize)
-      var L = getCurrentDirectoryA(bufsize, result)
-      if L == 0'i32: raiseOSError(osLastError())
-      setLen(result, L)
+      while true:
+        var L = getCurrentDirectoryA(bufsize, result)
+        if L == 0'i32:
+          raiseOSError(osLastError())
+        elif L > bufsize:
+          result = newString(L)
+          bufsize = L
+        else:
+          setLen(result, L)
+          break
   else:
+    var bufsize = 1024 # should be enough
     result = newString(bufsize)
-    if getcwd(result, bufsize) != nil:
-      setLen(result, c_strlen(result))
-    else:
-      raiseOSError(osLastError())
+    while true:
+      if getcwd(result, bufsize) != nil:
+        setLen(result, c_strlen(result))
+        break
+      else:
+        let err = osLastError()
+        if err.int32 == ERANGE:
+          bufsize = bufsize shl 1
+          doAssert(bufsize >= 0)
+          result = newString(bufsize)
+        else:
+          raiseOSError(osLastError())
 
 proc setCurrentDir*(newDir: string) {.inline, tags: [].} =
   ## Sets the `current working directory`:idx:; `OSError` is raised if
@@ -336,28 +361,45 @@ proc setCurrentDir*(newDir: string) {.inline, tags: [].} =
 
 proc expandFilename*(filename: string): string {.rtl, extern: "nos$1",
   tags: [ReadDirEffect].} =
-  ## Returns the full (`absolute`:idx:) path of the file `filename`, raises OSError in case of an error.
+  ## Returns the full (`absolute`:idx:) path of the file `filename`,
+  ## raises OSError in case of an error.
   when defined(windows):
-    const bufsize = 3072'i32
+    var bufsize = MAX_PATH.int32
     when useWinUnicode:
-      var unused: WideCString
-      var res = newWideCString("", bufsize div 2)
-      var L = getFullPathNameW(newWideCString(filename), bufsize, res, unused)
-      if L <= 0'i32 or L >= bufsize:
-        raiseOSError(osLastError())
-      result = res$L
+      var unused: WideCString = nil
+      var res = newWideCString("", bufsize)
+      while true:
+        var L = getFullPathNameW(newWideCString(filename), bufsize, res, unused)
+        if L == 0'i32:
+          raiseOSError(osLastError())
+        elif L > bufsize:
+          res = newWideCString("", L)
+          bufsize = L
+        else:
+          result = res$L
+          break
     else:
-      var unused: cstring
+      var unused: cstring = nil
       result = newString(bufsize)
-      var L = getFullPathNameA(filename, bufsize, result, unused)
-      if L <= 0'i32 or L >= bufsize: raiseOSError(osLastError())
-      setLen(result, L)
+      while true:
+        var L = getFullPathNameA(filename, bufsize, result, unused)
+        if L == 0'i32:
+          raiseOSError(osLastError())
+        elif L > bufsize:
+          result = newString(L)
+          bufsize = L
+        else:
+          setLen(result, L)
+          break
   else:
-    # careful, realpath needs to take an allocated buffer according to Posix:
-    result = newString(pathMax)
-    var r = realpath(filename, result)
-    if r.isNil: raiseOSError(osLastError())
-    setLen(result, c_strlen(result))
+    # according to Posix we don't need to allocate space for result pathname.
+    # But we need to free return value with free(3).
+    var r = realpath(filename, nil)
+    if r.isNil:
+      raiseOSError(osLastError())
+    else:
+      result = $r
+      c_free(cast[pointer](r))
 
 when defined(Windows):
   proc openHandle(path: string, followSymlink=true): Handle =
@@ -1382,6 +1424,35 @@ when declared(paramCount) or defined(nimdoc):
     for i in 1..paramCount():
       result.add(paramStr(i))
 
+when defined(freebsd):
+  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
+              newp: pointer, newplen: csize): cint
+       {.importc: "sysctl",header: """#include <sys/types.h>
+                                      #include <sys/sysctl.h>"""}
+  const
+    CTL_KERN = 1
+    KERN_PROC = 14
+    KERN_PROC_PATHNAME = 12
+    MAX_PATH = 1024
+
+  proc getApplFreebsd(): string =
+    var pathLength = csize(MAX_PATH)
+    result = newString(pathLength)
+    var req = [CTL_KERN.cint, KERN_PROC.cint, KERN_PROC_PATHNAME.cint, -1.cint]
+    while true:
+      let res = sysctl(addr req[0], 4, cast[pointer](addr result[0]),
+                       addr pathLength, nil, 0)
+      if res < 0:
+        let err = osLastError()
+        if err.int32 == ENOMEM:
+          result = newString(pathLength)
+        else:
+          result.setLen(0) # error!
+          break
+      else:
+        result.setLen(pathLength)
+        break
+
 when defined(linux) or defined(solaris) or defined(bsd) or defined(aix):
   proc getApplAux(procPath: string): string =
     result = newString(256)
@@ -1426,16 +1497,34 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
   # Solaris:
   # /proc/<pid>/object/a.out (filename only)
   # /proc/<pid>/path/a.out (complete pathname)
-  # FreeBSD: /proc/<pid>/file
   when defined(windows):
+    var bufsize = int32(MAX_PATH)
     when useWinUnicode:
-      var buf = newWideCString("", 256)
-      var len = getModuleFileNameW(0, buf, 256)
-      result = buf$len
+      var buf = newWideCString("", bufsize)
+      while true:
+        var L = getModuleFileNameW(0, buf, bufsize)
+        if L == 0'i32:
+          result = "" # error!
+          break
+        elif L > bufsize:
+          buf = newWideCString("", L)
+          bufsize = L
+        else:
+          result = buf$L
+          break
     else:
-      result = newString(256)
-      var len = getModuleFileNameA(0, result, 256)
-      setlen(result, int(len))
+      result = newString(bufsize)
+      while true:
+        var L = getModuleFileNameA(0, result, bufsize)
+        if L == 0'i32:
+          result = "" # error!
+          break
+        elif L > bufsize:
+          result = newString(L)
+          bufsize = L
+        else:
+          setLen(result, L)
+          break
   elif defined(macosx):
     var size: cuint32
     getExecPath1(nil, size)
@@ -1450,7 +1539,7 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
     elif defined(solaris):
       result = getApplAux("/proc/" & $getpid() & "/path/a.out")
     elif defined(freebsd):
-      result = getApplAux("/proc/" & $getpid() & "/file")
+      result = getApplFreebsd()
     # little heuristic that may work on other POSIX-like systems:
     if result.len == 0:
       result = getApplHeuristic()
diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim
index 56671ee62..3d3a105f0 100644
--- a/lib/pure/ospaths.nim
+++ b/lib/pure/ospaths.nim
@@ -434,8 +434,8 @@ when not declared(getEnv) or defined(nimscript):
     ## On Windows, network paths are considered absolute too.
     when doslike:
       var len = len(path)
-      result = (len > 1 and path[0] in {'/', '\\'}) or
-               (len > 2 and path[0] in {'a'..'z', 'A'..'Z'} and path[1] == ':')
+      result = (len > 0 and path[0] in {'/', '\\'}) or
+               (len > 1 and path[0] in {'a'..'z', 'A'..'Z'} and path[1] == ':')
     elif defined(macos):
       result = path.len > 0 and path[0] != ':'
     elif defined(RISCOS):
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index abc21b2b2..44ec5b548 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -48,7 +48,7 @@ type
       inHandle, outHandle, errHandle: FileHandle
       inStream, outStream, errStream: Stream
       id: Pid
-    exitCode: cint
+    exitStatus: cint
     options: set[ProcessOption]
 
   Process* = ref ProcessObj ## represents an operating system process
@@ -731,7 +731,7 @@ elif not defined(useNimRtl):
       pStdin, pStdout, pStderr: array[0..1, cint]
     new(result)
     result.options = options
-    result.exitCode = -3 # for ``waitForExit``
+    result.exitStatus = -3 # for ``waitForExit``
     if poParentStreams notin options:
       if pipe(pStdin) != 0'i32 or pipe(pStdout) != 0'i32 or
          pipe(pStderr) != 0'i32:
@@ -774,7 +774,10 @@ elif not defined(useNimRtl):
     data.workingDir = workingDir
 
     when useProcessAuxSpawn:
+      var currentDir = getCurrentDir()
       pid = startProcessAuxSpawn(data)
+      if workingDir.len > 0:
+        setCurrentDir(currentDir)
     else:
       pid = startProcessAuxFork(data)
 
@@ -835,7 +838,6 @@ elif not defined(useNimRtl):
           chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
 
       var res: cint
-      # FIXME: chdir is global to process
       if data.workingDir.len > 0:
         setCurrentDir($data.workingDir)
       var pid: Pid
@@ -957,13 +959,10 @@ elif not defined(useNimRtl):
 
   proc running(p: Process): bool =
     var ret : int
-    when not defined(freebsd):
-      ret = waitpid(p.id, p.exitCode, WNOHANG)
-    else:
-      var status : cint = 1
-      ret = waitpid(p.id, status, WNOHANG)
-      if WIFEXITED(status):
-        p.exitCode = status
+    var status : cint = 1
+    ret = waitpid(p.id, status, WNOHANG)
+    if WIFEXITED(status):
+      p.exitStatus = status
     if ret == 0: return true # Can't establish status. Assume running.
     result = ret == int(p.id)
 
@@ -980,11 +979,12 @@ elif not defined(useNimRtl):
     import kqueue, times
 
     proc waitForExit(p: Process, timeout: int = -1): int =
-      if p.exitCode != -3: return p.exitCode
+      if p.exitStatus != -3: return int(p.exitStatus) shr 8
       if timeout == -1:
-        if waitpid(p.id, p.exitCode, 0) < 0:
-          p.exitCode = -3
+        var status : cint = 1
+        if waitpid(p.id, status, 0) < 0:
           raiseOSError(osLastError())
+        p.exitStatus = status
       else:
         var kqFD = kqueue()
         if kqFD == -1:
@@ -1004,6 +1004,7 @@ elif not defined(useNimRtl):
 
         try:
           while true:
+            var status : cint = 1
             var count = kevent(kqFD, addr(kevIn), 1, addr(kevOut), 1,
                                addr(tmspec))
             if count < 0:
@@ -1014,22 +1015,22 @@ elif not defined(useNimRtl):
               # timeout expired, so we trying to kill process
               if posix.kill(p.id, SIGKILL) == -1:
                 raiseOSError(osLastError())
-              if waitpid(p.id, p.exitCode, 0) < 0:
-                p.exitCode = -3
+              if waitpid(p.id, status, 0) < 0:
                 raiseOSError(osLastError())
+              p.exitStatus = status
               break
             else:
               if kevOut.ident == p.id.uint and kevOut.filter == EVFILT_PROC:
-                if waitpid(p.id, p.exitCode, 0) < 0:
-                  p.exitCode = -3
+                if waitpid(p.id, status, 0) < 0:
                   raiseOSError(osLastError())
+                p.exitStatus = status
                 break
               else:
                 raiseOSError(osLastError())
         finally:
           discard posix.close(kqFD)
 
-      result = int(p.exitCode) shr 8
+      result = int(p.exitStatus) shr 8
   else:
     import times
 
@@ -1061,15 +1062,16 @@ elif not defined(useNimRtl):
         s.tv_sec = b.tv_sec
         s.tv_nsec = b.tv_nsec
 
-      #if waitPid(p.id, p.exitCode, 0) == int(p.id):
+      #if waitPid(p.id, p.exitStatus, 0) == int(p.id):
       # ``waitPid`` fails if the process is not running anymore. But then
-      # ``running`` probably set ``p.exitCode`` for us. Since ``p.exitCode`` is
+      # ``running`` probably set ``p.exitStatus`` for us. Since ``p.exitStatus`` is
       # initialized with -3, wrong success exit codes are prevented.
-      if p.exitCode != -3: return p.exitCode
+      if p.exitStatus != -3: return int(p.exitStatus) shr 8
       if timeout == -1:
-        if waitpid(p.id, p.exitCode, 0) < 0:
-          p.exitCode = -3
+        var status : cint = 1
+        if waitpid(p.id, status, 0) < 0:
           raiseOSError(osLastError())
+        p.exitStatus = status
       else:
         var nmask, omask: Sigset
         var sinfo: SigInfo
@@ -1100,9 +1102,10 @@ elif not defined(useNimRtl):
             let res = sigtimedwait(nmask, sinfo, tmspec)
             if res == SIGCHLD:
               if sinfo.si_pid == p.id:
-                if waitpid(p.id, p.exitCode, 0) < 0:
-                  p.exitCode = -3
+                var status : cint = 1
+                if waitpid(p.id, status, 0) < 0:
                   raiseOSError(osLastError())
+                p.exitStatus = status
                 break
               else:
                 # we have SIGCHLD, but not for process we are waiting,
@@ -1122,9 +1125,10 @@ elif not defined(useNimRtl):
                 # timeout expired, so we trying to kill process
                 if posix.kill(p.id, SIGKILL) == -1:
                   raiseOSError(osLastError())
-                if waitpid(p.id, p.exitCode, 0) < 0:
-                  p.exitCode = -3
+                var status : cint = 1
+                if waitpid(p.id, status, 0) < 0:
                   raiseOSError(osLastError())
+                p.exitStatus = status
                 break
               else:
                 raiseOSError(err)
@@ -1136,17 +1140,19 @@ elif not defined(useNimRtl):
             if sigprocmask(SIG_UNBLOCK, nmask, omask) == -1:
               raiseOSError(osLastError())
 
-      result = int(p.exitCode) shr 8
+      result = int(p.exitStatus) shr 8
 
   proc peekExitCode(p: Process): int =
-    if p.exitCode != -3: return p.exitCode
-    var ret = waitpid(p.id, p.exitCode, WNOHANG)
+    var status : cint = 1
+    if p.exitStatus != -3: return int(p.exitStatus) shr 8
+    var ret = waitpid(p.id, status, WNOHANG)
     var b = ret == int(p.id)
     if b: result = -1
-    if not WIFEXITED(p.exitCode):
-      p.exitCode = -3
+    if WIFEXITED(status):
+      p.exitStatus = status
+      result = p.exitStatus.int shr 8
+    else:
       result = -1
-    else: result = p.exitCode.int shr 8
 
   proc createStream(stream: var Stream, handle: var FileHandle,
                     fileMode: FileMode) =
diff --git a/lib/pure/parsexml.nim b/lib/pure/parsexml.nim
index d16a55302..aa4a13ecf 100644
--- a/lib/pure/parsexml.nim
+++ b/lib/pure/parsexml.nim
@@ -142,9 +142,9 @@ proc kind*(my: XmlParser): XmlEventKind {.inline.} =
 template charData*(my: XmlParser): string =
   ## returns the character data for the events: ``xmlCharData``,
   ## ``xmlWhitespace``, ``xmlComment``, ``xmlCData``, ``xmlSpecial``
-  ## Raises an assertion in debug mode if ``my.kind`` is not one 
+  ## Raises an assertion in debug mode if ``my.kind`` is not one
   ## of those events. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind in {xmlCharData, xmlWhitespace, xmlComment, xmlCData,
                      xmlSpecial})
   my.a
@@ -152,49 +152,49 @@ template charData*(my: XmlParser): string =
 template elementName*(my: XmlParser): string =
   ## returns the element name for the events: ``xmlElementStart``,
   ## ``xmlElementEnd``, ``xmlElementOpen``
-  ## Raises an assertion in debug mode if ``my.kind`` is not one 
+  ## Raises an assertion in debug mode if ``my.kind`` is not one
   ## of those events. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind in {xmlElementStart, xmlElementEnd, xmlElementOpen})
   my.a
 
 template entityName*(my: XmlParser): string =
   ## returns the entity name for the event: ``xmlEntity``
-  ## Raises an assertion in debug mode if ``my.kind`` is not 
+  ## Raises an assertion in debug mode if ``my.kind`` is not
   ## ``xmlEntity``. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind == xmlEntity)
   my.a
 
 template attrKey*(my: XmlParser): string =
   ## returns the attribute key for the event ``xmlAttribute``
-  ## Raises an assertion in debug mode if ``my.kind`` is not 
+  ## Raises an assertion in debug mode if ``my.kind`` is not
   ## ``xmlAttribute``. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind == xmlAttribute)
   my.a
 
 template attrValue*(my: XmlParser): string =
   ## returns the attribute value for the event ``xmlAttribute``
-  ## Raises an assertion in debug mode if ``my.kind`` is not 
+  ## Raises an assertion in debug mode if ``my.kind`` is not
   ## ``xmlAttribute``. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind == xmlAttribute)
   my.b
 
 template piName*(my: XmlParser): string =
   ## returns the processing instruction name for the event ``xmlPI``
-  ## Raises an assertion in debug mode if ``my.kind`` is not 
+  ## Raises an assertion in debug mode if ``my.kind`` is not
   ## ``xmlPI``. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind == xmlPI)
   my.a
 
 template piRest*(my: XmlParser): string =
   ## returns the rest of the processing instruction for the event ``xmlPI``
-  ## Raises an assertion in debug mode if ``my.kind`` is not 
+  ## Raises an assertion in debug mode if ``my.kind`` is not
   ## ``xmlPI``. In release mode, this will not trigger an error
-  ## but the value returned will not be valid. 
+  ## but the value returned will not be valid.
   assert(my.kind == xmlPI)
   my.b
 
@@ -636,12 +636,14 @@ proc rawGetTok(my: var XmlParser) =
 
 proc getTok(my: var XmlParser) =
   while true:
+    let lastKind = my.kind
     rawGetTok(my)
     case my.kind
     of xmlComment:
       if my.options.contains(reportComments): break
     of xmlWhitespace:
-      if my.options.contains(reportWhitespace): break
+      if my.options.contains(reportWhitespace) or lastKind in {xmlCharData, xmlComment, xmlEntity}:
+        break
     else: break
 
 proc next*(my: var XmlParser) =
diff --git a/lib/pure/random.nim b/lib/pure/random.nim
index 08da771dc..955a70143 100644
--- a/lib/pure/random.nim
+++ b/lib/pure/random.nim
@@ -122,7 +122,7 @@ when isMainModule:
       inc occur[x]
     for i, oc in occur:
       if oc < 69:
-        doAssert false, "too few occurances of " & $i
+        doAssert false, "too few occurrences of " & $i
       elif oc > 130:
-        doAssert false, "too many occurances of " & $i
+        doAssert false, "too many occurrences of " & $i
   main()
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index b78a2b966..efc1dfa92 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -266,13 +266,13 @@ proc initInterval*(milliseconds, seconds, minutes, hours, days, months,
   result.milliseconds = `mod`(milliseconds, 1000)
   carryO = `div`(milliseconds, 1000)
   result.seconds = `mod`(carryO + seconds, 60)
-  carryO = `div`(seconds, 60)
+  carryO = `div`(carryO + seconds, 60)
   result.minutes = `mod`(carryO + minutes, 60)
-  carryO = `div`(minutes, 60)
+  carryO = `div`(carryO + minutes, 60)
   result.hours = `mod`(carryO + hours, 24)
-  carryO = `div`(hours, 24)
+  carryO = `div`(carryO + hours, 24)
   result.days = carryO + days
-  carryO = 0
+
   result.months = `mod`(months, 12)
   carryO = `div`(months, 12)
   result.years = carryO + years
@@ -283,13 +283,13 @@ proc `+`*(ti1, ti2: TimeInterval): TimeInterval =
   result.milliseconds = `mod`(ti1.milliseconds + ti2.milliseconds, 1000)
   carryO = `div`(ti1.milliseconds + ti2.milliseconds, 1000)
   result.seconds = `mod`(carryO + ti1.seconds + ti2.seconds, 60)
-  carryO = `div`(ti1.seconds + ti2.seconds, 60)
+  carryO = `div`(carryO + ti1.seconds + ti2.seconds, 60)
   result.minutes = `mod`(carryO + ti1.minutes + ti2.minutes, 60)
-  carryO = `div`(ti1.minutes + ti2.minutes, 60)
+  carryO = `div`(carryO + ti1.minutes + ti2.minutes, 60)
   result.hours = `mod`(carryO + ti1.hours + ti2.hours, 24)
-  carryO = `div`(ti1.hours + ti2.hours, 24)
+  carryO = `div`(carryO + ti1.hours + ti2.hours, 24)
   result.days = carryO + ti1.days + ti2.days
-  carryO = 0
+
   result.months = `mod`(ti1.months + ti2.months, 12)
   carryO = `div`(ti1.months + ti2.months, 12)
   result.years = carryO + ti1.years + ti2.years
@@ -1248,12 +1248,18 @@ proc parse*(value, layout: string): TimeInfo =
       else:
         parseToken(info, token, value, j)
         token = ""
-  # Reset weekday (might not have been provided and the default may be wrong)
-  # and yearday (is never provided directly and therefore probably wrong)
-  let processed = getLocalTime(toTime(info))
-  info.weekday = processed.weekday
-  info.yearday = processed.yearday
-  return info
+
+  # We are going to process the date to find out if we are in DST, because the
+  # default based on the current time may be wrong. Calling getLocalTime will
+  # set this correctly, but the actual time may be offset from when we called
+  # toTime with a possibly incorrect DST setting, so we are only going to take
+  # the isDST from this result.
+  let correctDST = getLocalTime(toTime(info))
+  info.isDST = correctDST.isDST
+
+  # Now we preocess it again with the correct isDST to correct things like
+  # weekday and yearday.
+  return getLocalTime(toTime(info))
 
 # Leap year calculations are adapted from:
 # http://www.codeproject.com/Articles/7358/Ultra-fast-Algorithms-for-Working-with-Leap-Years
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index 0fc2e441e..12553e3da 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -11,11 +11,21 @@
 ##
 ## This module implements boilerplate to make unit testing easy.
 ##
+## The test status and name is printed after any output or traceback.
+##
 ## Example:
 ##
 ## .. code:: nim
 ##
 ##   suite "description for this stuff":
+##     echo "suite setup: run once before the tests"
+##
+##     setup:
+##       echo "run before each test"
+##
+##     teardown:
+##       echo "run after each test":
+##
 ##     test "essential truths":
 ##       # give up and stop if this fails
 ##       require(true)
@@ -30,6 +40,13 @@
 ##       let v = @[1, 2, 3]  # you can do initialization here
 ##       expect(IndexError):
 ##         discard v[4]
+##
+##     echo "suite teardown: run once after the tests"
+##
+##
+## Tests can be nested, however failure of a nested test will not mark the
+## parent test as failed. Setup and teardown are inherited. Setup can be
+## overridden locally.
 
 import
   macros
@@ -226,10 +243,11 @@ template fail* =
   checkpoints = @[]
 
 template skip* =
-  ## Makes test to be skipped. Should be used directly
+  ## Mark the test as skipped. Should be used directly
   ## in case when it is not possible to perform test
   ## for reasons depending on outer environment,
   ## or certain application logic conditions or configurations.
+  ## The test code is still executed.
   ##
   ## .. code-block:: nim
   ##
@@ -250,12 +268,12 @@ macro check*(conditions: untyped): untyped =
   ##
   ##  import strutils
   ##
-  ##  check("AKB48".toLower() == "akb48")
+  ##  check("AKB48".toLowerAscii() == "akb48")
   ##
   ##  let teams = {'A', 'K', 'B', '4', '8'}
   ##
   ##  check:
-  ##    "AKB48".toLower() == "akb48"
+  ##    "AKB48".toLowerAscii() == "akb48"
   ##    'C' in teams
   let checked = callsite()[1]
   var
diff --git a/lib/pure/xmlparser.nim b/lib/pure/xmlparser.nim
index 2a2c3e1dd..22bd259b7 100644
--- a/lib/pure/xmlparser.nim
+++ b/lib/pure/xmlparser.nim
@@ -28,7 +28,7 @@ proc raiseInvalidXml(errors: seq[string]) =
 proc addNode(father, son: XmlNode) =
   if son != nil: add(father, son)
 
-proc parse(x: var XmlParser, errors: var seq[string]): XmlNode
+proc parse(x: var XmlParser, errors: var seq[string]): XmlNode {.gcsafe.}
 
 proc untilElementEnd(x: var XmlParser, result: XmlNode,
                      errors: var seq[string]) =
@@ -164,3 +164,6 @@ when isMainModule:
       var xml = loadXml(filePath, errors)
       assert(errors.len == 0, "The file tests/testdata/doc1.xml should be parsed without errors.")
 
+    block bug1518:
+      var err: seq[string] = @[]
+      assert $parsexml(newStringStream"<tag>One &amp; two</tag>", "temp.xml", err) == "<tag>One &amp; two</tag>"
diff --git a/lib/stdlib.nimble b/lib/stdlib.nimble
index 1071ee1d8..5238d900b 100644
--- a/lib/stdlib.nimble
+++ b/lib/stdlib.nimble
@@ -1,6 +1,6 @@
 [Package]
 name          = "stdlib"
-version       = "0.15.0"
+version       = "0.15.2"
 author        = "Dominik Picheta"
 description   = "Nim's standard library."
 license       = "MIT"
diff --git a/lib/system.nim b/lib/system.nim
index 07fcbd369..919b4694c 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1827,7 +1827,7 @@ const
   NimMinor*: int = 15
     ## is the minor number of Nim's version.
 
-  NimPatch*: int = 0
+  NimPatch*: int = 2
     ## is the patch number of Nim's version.
 
   NimVersion*: string = $NimMajor & "." & $NimMinor & "." & $NimPatch
@@ -2581,10 +2581,11 @@ else:
 when not defined(JS): #and not defined(nimscript):
   {.push stack_trace: off, profiler:off.}
 
-  when not defined(nimscript) and not defined(nogc):
+  when hasAlloc:
     when not defined(gcStack):
       proc initGC()
-    when not defined(boehmgc) and not defined(useMalloc) and not defined(gogc) and not defined(gcStack):
+    when not defined(boehmgc) and not defined(useMalloc) and
+        not defined(gogc) and not defined(gcStack):
       proc initAllocator() {.inline.}
 
     proc initStackBottom() {.inline, compilerproc.} =
@@ -2602,7 +2603,6 @@ when not defined(JS): #and not defined(nimscript):
       when declared(setStackBottom):
         setStackBottom(locals)
 
-  when hasAlloc:
     var
       strDesc = TNimType(size: sizeof(string), kind: tyString, flags: {ntfAcyclic})
 
@@ -2731,7 +2731,7 @@ when not defined(JS): #and not defined(nimscript):
     proc setStdIoUnbuffered*() {.tags: [], benign.}
       ## Configures `stdin`, `stdout` and `stderr` to be unbuffered.
 
-    proc close*(f: File) {.tags: [].}
+    proc close*(f: File) {.tags: [], gcsafe.}
       ## Closes the file.
 
     proc endOfFile*(f: File): bool {.tags: [], benign.}
@@ -3676,7 +3676,7 @@ template closureScope*(body: untyped): untyped =
 when defined(nimconfig):
   include "system/nimscript"
 
-when defined(windows) and appType == "console" and not defined(nimconfig):
+when defined(windows) and appType == "console" and defined(nimSetUtf8CodePage):
   proc setConsoleOutputCP(codepage: cint): cint {.stdcall, dynlib: "kernel32",
     importc: "SetConsoleOutputCP".}
   discard setConsoleOutputCP(65001) # 65001 - utf-8 codepage
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
index 0a994efac..fa997e982 100644
--- a/lib/system/dyncalls.nim
+++ b/lib/system/dyncalls.nim
@@ -26,6 +26,8 @@ proc nimLoadLibraryError(path: string) =
   stderr.rawWrite("could not load: ")
   stderr.rawWrite(path)
   stderr.rawWrite("\n")
+  when not(defined(nimDebugDlOpen)):
+    stderr.rawWrite("compile with -d:nimDebugDlOpen for more information\n")
   quit(1)
 
 proc procAddrError(name: cstring) {.noinline.} =
@@ -74,7 +76,8 @@ when defined(posix):
     when defined(nimDebugDlOpen):
       let error = dlerror()
       if error != nil:
-        c_fprintf(c_stderr, "%s\n", error)
+        stderr.write(error)
+        stderr.rawWrite("\n")
 
   proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
     result = dlsym(lib, name)
diff --git a/lib/system/gc2.nim b/lib/system/gc2.nim
index 089c9c915..ce2bfc2ae 100644
--- a/lib/system/gc2.nim
+++ b/lib/system/gc2.nim
@@ -33,6 +33,9 @@ when withRealTime and not declared(getTicks):
 when defined(memProfiler):
   proc nimProfile(requestedSize: int) {.benign.}
 
+when hasThreadSupport:
+  include sharedlist
+
 type
   ObjectSpaceIter = object
     state: range[-1..0]
@@ -96,7 +99,7 @@ type
     stat: GcStat
     additionalRoots: CellSeq # dummy roots for GC_ref/unref
     spaceIter: ObjectSpaceIter
-    dumpHeapFile: File # File that is used for GC_dumpHeap
+    pDumpHeapFile: pointer # File that is used for GC_dumpHeap
     when hasThreadSupport:
       toDispose: SharedList[pointer]
 
@@ -612,6 +615,9 @@ template checkTime {.dirty.} =
 
 # ---------------- dump heap ----------------
 
+template dumpHeapFile(gch: var GcHeap): File =
+  cast[File](gch.pDumpHeapFile)
+
 proc debugGraph(s: PCell) =
   c_fprintf(gch.dumpHeapFile, "child %p\n", s)
 
@@ -625,7 +631,7 @@ proc GC_dumpHeap*(file: File) =
   ## Dumps the GCed heap's content to a file. Can be useful for
   ## debugging. Produces an undocumented text file format that
   ## can be translated into "dot" syntax via the "heapdump2dot" tool.
-  gch.dumpHeapFile = file
+  gch.pDumpHeapFile = file
   var spaceIter: ObjectSpaceIter
   var d = gch.decStack.d
   for i in 0 .. < gch.decStack.len:
@@ -643,7 +649,7 @@ proc GC_dumpHeap*(file: File) =
       writeCell(file, "cell ", c)
       forAllChildren(c, waDebug)
       c_fprintf(file, "end\n")
-  gch.dumpHeapFile = nil
+  gch.pDumpHeapFile = nil
 
 proc GC_dumpHeap() =
   var f: File
diff --git a/lib/system/gc_common.nim b/lib/system/gc_common.nim
index 7a1b88c84..513ede173 100644
--- a/lib/system/gc_common.nim
+++ b/lib/system/gc_common.nim
@@ -120,6 +120,7 @@ when allowForeignThreadGc:
     ## switches are used
     if not localGcInitialized:
       localGcInitialized = true
+      initAllocator()
       var stackTop {.volatile.}: pointer
       setStackBottom(addr(stackTop))
       initGC()
diff --git a/lib/system/gc_stack.nim b/lib/system/gc_stack.nim
index 5f72b8959..3eda08df9 100644
--- a/lib/system/gc_stack.nim
+++ b/lib/system/gc_stack.nim
@@ -79,6 +79,7 @@ template withRegion*(r: MemRegion; body: untyped) =
   try:
     body
   finally:
+    r = tlRegion
     tlRegion = oldRegion
 
 template inc(p: pointer, s: int) =
@@ -464,4 +465,10 @@ proc getFreeMem(): int = tlRegion.remaining
 proc getTotalMem(): int =
   result = tlRegion.totalSize
 
+proc getOccupiedMem*(r: MemRegion): int =
+  result = r.totalSize - r.remaining
+proc getFreeMem*(r: MemRegion): int = r.remaining
+proc getTotalMem*(r: MemRegion): int =
+  result = r.totalSize
+
 proc setStackBottom(theStackBottom: pointer) = discard
diff --git a/lib/system/hti.nim b/lib/system/hti.nim
index 984f888cb..892a209df 100644
--- a/lib/system/hti.nim
+++ b/lib/system/hti.nim
@@ -62,7 +62,6 @@ type
     tyUInt16,
     tyUInt32,
     tyUInt64,
-    tyBigNum,
 
   TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
   TNimNode {.codegenType.} = object
diff --git a/lib/system/osalloc.nim b/lib/system/osalloc.nim
index b07a362a0..316dd74d7 100644
--- a/lib/system/osalloc.nim
+++ b/lib/system/osalloc.nim
@@ -87,8 +87,6 @@ elif defined(posix):
     const MAP_ANONYMOUS = 0x1000
   elif defined(solaris):
     const MAP_ANONYMOUS = 0x100
-  elif defined(linux):
-    const MAP_ANONYMOUS = 0x20
   else:
     var
       MAP_ANONYMOUS {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 3e9657ce0..5c10392f1 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -104,21 +104,22 @@ proc getFileHandle*(f: File): FileHandle = c_fileno(f)
 
 proc readLine(f: File, line: var TaintedString): bool =
   var pos = 0
+  var sp: cint = 80
   # Use the currently reserved space for a first try
-  when defined(nimscript):
-    var space: cint = 80
+  if line.string.isNil:
+    line = TaintedString(newStringOfCap(80))
   else:
-    var space: cint = cint(cast[PGenericSeq](line.string).space)
-  line.string.setLen(space)
-
+    when not defined(nimscript):
+      sp = cint(cast[PGenericSeq](line.string).space)
+    line.string.setLen(sp)
   while true:
     # memset to \l so that we can tell how far fgets wrote, even on EOF, where
     # fgets doesn't append an \l
-    c_memset(addr line.string[pos], '\l'.ord, space)
-    if c_fgets(addr line.string[pos], space, f) == nil:
+    c_memset(addr line.string[pos], '\l'.ord, sp)
+    if c_fgets(addr line.string[pos], sp, f) == nil:
       line.string.setLen(0)
       return false
-    let m = c_memchr(addr line.string[pos], '\l'.ord, space)
+    let m = c_memchr(addr line.string[pos], '\l'.ord, sp)
     if m != nil:
       # \l found: Could be our own or the one by fgets, in any case, we're done
       var last = cast[ByteAddress](m) - cast[ByteAddress](addr line.string[0])
@@ -129,17 +130,17 @@ proc readLine(f: File, line: var TaintedString): bool =
         # \0\l\0 => line ending in a null character.
         # \0\l\l => last line without newline, null was put there by fgets.
       elif last > 0 and line.string[last-1] == '\0':
-        if last < pos + space - 1 and line.string[last+1] != '\0':
+        if last < pos + sp - 1 and line.string[last+1] != '\0':
           dec last
       line.string.setLen(last)
       return true
     else:
       # fgets will have inserted a null byte at the end of the string.
-      dec space
+      dec sp
     # No \l found: Increase buffer and read more
-    inc pos, space
-    space = 128 # read in 128 bytes at a time
-    line.string.setLen(pos+space)
+    inc pos, sp
+    sp = 128 # read in 128 bytes at a time
+    line.string.setLen(pos+sp)
 
 proc readLine(f: File): TaintedString =
   result = TaintedString(newStringOfCap(80))
diff --git a/lib/upcoming/asyncdispatch.nim b/lib/upcoming/asyncdispatch.nim
index 29b955c46..731ef52dc 100644
--- a/lib/upcoming/asyncdispatch.nim
+++ b/lib/upcoming/asyncdispatch.nim
@@ -1194,21 +1194,21 @@ else:
         var fd = keys[i].fd.SocketHandle
         let events = keys[i].events
 
-        if Event.Read in events:
+        if Event.Read in events or events == {Event.Error}:
           let cb = keys[i].data.readCB
-          doAssert(cb != nil)
-          if cb(fd.AsyncFD):
-            p.selector.withData(fd, adata) do:
-              if adata.readCB == cb:
-                adata.readCB = nil
+          if cb != nil:
+            if cb(fd.AsyncFD):
+              p.selector.withData(fd, adata) do:
+                if adata.readCB == cb:
+                  adata.readCB = nil
 
-        if Event.Write in events:
+        if Event.Write in events or events == {Event.Error}:
           let cb = keys[i].data.writeCB
-          doAssert(cb != nil)
-          if cb(fd.AsyncFD):
-            p.selector.withData(fd, adata) do:
-              if adata.writeCB == cb:
-                adata.writeCB = nil
+          if cb != nil:
+            if cb(fd.AsyncFD):
+              p.selector.withData(fd, adata) do:
+                if adata.writeCB == cb:
+                  adata.writeCB = nil
 
         when supportedPlatform:
           if (customSet * events) != {}:
diff --git a/lib/windows/registry.nim b/lib/windows/registry.nim
new file mode 100644
index 000000000..06f84c881
--- /dev/null
+++ b/lib/windows/registry.nim
@@ -0,0 +1,77 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module is experimental and its interface may change.
+
+import winlean, os
+
+type
+  HKEY* = uint
+
+const
+  HKEY_LOCAL_MACHINE* = HKEY(0x80000002u)
+  HKEY_CURRENT_USER* = HKEY(2147483649)
+
+  RRF_RT_ANY = 0x0000ffff
+  KEY_WOW64_64KEY = 0x0100
+  KEY_WOW64_32KEY = 0x0200
+  KEY_READ = 0x00020019
+  REG_SZ = 1
+
+proc regOpenKeyEx(hKey: HKEY, lpSubKey: WideCString, ulOptions: int32,
+                  samDesired: int32,
+                  phkResult: var HKEY): int32 {.
+  importc: "RegOpenKeyExW", dynlib: "Advapi32.dll", stdcall.}
+
+proc regCloseKey(hkey: HKEY): int32 {.
+  importc: "RegCloseKey", dynlib: "Advapi32.dll", stdcall.}
+
+proc regGetValue(key: HKEY, lpSubKey, lpValue: WideCString;
+                 dwFlags: int32 = RRF_RT_ANY, pdwType: ptr int32,
+                 pvData: pointer,
+                 pcbData: ptr int32): int32 {.
+  importc: "RegGetValueW", dynlib: "Advapi32.dll", stdcall.}
+
+template call(f) =
+  let err = f
+  if err != 0:
+    raiseOSError(err.OSErrorCode, astToStr(f))
+
+proc getUnicodeValue*(path, key: string; handle: HKEY): string =
+  let hh = newWideCString path
+  let kk = newWideCString key
+  var bufsize: int32
+  # try a couple of different flag settings:
+  var flags: int32 = RRF_RT_ANY
+  let err = regGetValue(handle, hh, kk, flags, nil, nil, addr bufsize)
+  if err != 0:
+    var newHandle: HKEY
+    call regOpenKeyEx(handle, hh, 0, KEY_READ or KEY_WOW64_64KEY, newHandle)
+    call regGetValue(newHandle, nil, kk, flags, nil, nil, addr bufsize)
+    var res = newWideCString("", bufsize)
+    call regGetValue(newHandle, nil, kk, flags, nil, cast[pointer](res),
+                   addr bufsize)
+    result = res $ bufsize
+    call regCloseKey(newHandle)
+  else:
+    var res = newWideCString("", bufsize)
+    call regGetValue(handle, hh, kk, flags, nil, cast[pointer](res),
+                   addr bufsize)
+    result = res $ bufsize
+
+proc regSetValue(key: HKEY, lpSubKey, lpValueName: WideCString,
+                 dwType: int32; lpData: WideCString; cbData: int32): int32 {.
+  importc: "RegSetKeyValueW", dynlib: "Advapi32.dll", stdcall.}
+
+proc setUnicodeValue*(path, key, val: string; handle: HKey) =
+  let hh = newWideCString path
+  let kk = newWideCString key
+  let vv = newWideCString val
+  call regSetValue(handle, hh, kk, REG_SZ, vv, (vv.len.int32+1)*2)
+
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 9dad7e489..204e5bb40 100644
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -26,7 +26,7 @@ when useWinVersion:
   from winlean import SocketHandle
 else:
   const
-    versions = "(|.10|.1.0.1|.1.0.0|.0.9.9|.0.9.8)"
+    versions = "(|.10|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8)"
   when defined(macosx):
     const
       DLLSSLName = "libssl" & versions & ".dylib"
diff --git a/readme.md b/readme.md
index 01061bfa2..b4a484f60 100644
--- a/readme.md
+++ b/readme.md
@@ -27,7 +27,8 @@ To build from source you will need:
     are: clang, Visual C++, Intel's C++ compiler
   * git or wget
 
-**Note:** When installing ``gcc`` on Ubuntu (and likely other distros) ensure that the ``build-essentials`` package is installed also.
+**Note:** When installing ``gcc`` on Ubuntu (and likely other distros) ensure
+that the ``build-essentials`` package is installed also.
 
 If you are on a fairly modern *nix system, the following steps should work:
 
@@ -51,13 +52,6 @@ instead of ``build.sh``.
 The ``koch`` tool is the Nim build tool, more ``koch`` related options are
 documented in [doc/koch.rst](doc/koch.rst).
 
-To complete the installation you should also build Nim's tools like
-``nimsuggest``, ``nimble`` or ``nimgrep``:
-
-```
-nim e install_tools.nims
-```
-
 
 ## Nimble
 [Nimble](https://github.com/nim-lang/nimble) is Nim's package manager. For the
@@ -65,15 +59,9 @@ source based installations where you added Nim's ``bin`` directory to your PATH
 the easiest way of installing Nimble is via:
 
 ```
-$ nim e install_nimble.nims
+$ koch nimble
 ```
 
-**Warning:** If you install Nimble this way, you will not be able to use binary
-Nimble packages or update Nimble easily.
-The [Nimble readme](https://github.com/nim-lang/nimble#installation)
-provides thorough instructions on how to install Nimble, so that this isn't a
-problem.
-
 ## Community
 [![Join the Chat at irc.freenode.net#nim](https://img.shields.io/badge/IRC-join_chat_in_%23nim-blue.svg)](https://webchat.freenode.net/?channels=nim)
 [![Join the Gitter channel](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nim-lang/Nim)
diff --git a/tests/async/tasynceverror.nim b/tests/async/tasynceverror.nim
deleted file mode 100644
index dd05c831b..000000000
--- a/tests/async/tasynceverror.nim
+++ /dev/null
@@ -1,66 +0,0 @@
-discard """
-  file: "tasynceverror.nim"
-  exitcode: 1
-  outputsub: "Error: unhandled exception: "
-"""
-# error message is actually different on OSX
-import
-    asyncdispatch,
-    asyncnet,
-    nativesockets,
-    os
-
-
-const
-    testHost = "127.0.0.1"
-    testPort = Port(17357)
-
-
-when defined(windows) or defined(nimdoc):
-    # TODO: just make it work on Windows for now.
-    quit("Error: unhandled exception: Connection reset by peer")
-else:
-    proc createListenSocket(host: string, port: Port): TAsyncFD =
-        result = newAsyncNativeSocket()
-
-        SocketHandle(result).setSockOptInt(SOL_SOCKET, SO_REUSEADDR, 1)
-
-        var aiList = getAddrInfo(host, port, AF_INET)
-        if SocketHandle(result).bindAddr(aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32:
-          dealloc(aiList)
-          raiseOSError(osLastError())
-        dealloc(aiList)
-
-        if SocketHandle(result).listen(1) < 0'i32:
-            raiseOSError(osLastError())
-
-
-    proc testAsyncSend() {.async.} =
-        var
-            ls = createListenSocket(testHost, testPort)
-            s = newAsyncSocket()
-
-        await s.connect(testHost, testPort)
-
-        var ps = await ls.accept()
-        closeSocket(ls)
-
-        await ps.send("test 1", flags={})
-        s.close()
-        # This send should raise EPIPE
-        await ps.send("test 2", flags={})
-        SocketHandle(ps).close()
-
-
-    # The bug was, when the poll function handled EvError for us,
-    # our callbacks may never get executed, thus making the event
-    # loop block indefinitely. This is a timer to keep everything
-    # rolling. 400 ms is an arbitrary value, should be enough though.
-    proc timer() {.async.} =
-        await sleepAsync(400)
-        echo("Timer expired.")
-        quit(2)
-
-
-    asyncCheck(testAsyncSend())
-    waitFor(timer())
diff --git a/tests/async/tgenericasync.nim b/tests/async/tgenericasync.nim
new file mode 100644
index 000000000..ab704238a
--- /dev/null
+++ b/tests/async/tgenericasync.nim
@@ -0,0 +1,14 @@
+discard """
+  output: '''123
+abc'''
+"""
+
+# bug #4856
+
+import asyncdispatch
+
+proc say[T](t: T): Future[void] {.async.} =
+  echo $t
+
+waitFor(say(123))
+waitFor(say("abc"))
diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim
index 59fef4920..4f286d0ed 100644
--- a/tests/collections/ttables.nim
+++ b/tests/collections/ttables.nim
@@ -95,9 +95,24 @@ block orderedTableTest1:
   for key, val in mpairs(t): val = 99
   for val in mvalues(t): assert val == 99
 
+block orderedTableTest2:
+  var
+    s = initOrderedTable[string, int]()
+    t = initOrderedTable[string, int]()
+  assert s == t
+  for key, val in items(data): t[key] = val
+  assert s != t
+  for key, val in items(sorteddata): s[key] = val
+  assert s != t
+  t.clear()
+  assert s != t
+  for key, val in items(sorteddata): t[key] = val
+  assert s == t
+
 block countTableTest1:
   var s = data.toTable
   var t = initCountTable[string]()
+  
   for k in s.keys: t.inc(k)
   for k in t.keys: assert t[k] == 1
   t.inc("90", 3)
@@ -115,6 +130,24 @@ block countTableTest1:
     else: break
     inc i
 
+block countTableTest2:
+  var
+    s = initCountTable[int]()
+    t = initCountTable[int]()
+  assert s == t
+  s.inc(1)
+  assert s != t
+  t.inc(2)
+  assert s != t
+  t.inc(1)
+  assert s != t
+  s.inc(2)
+  assert s == t
+  s.inc(1)
+  assert s != t
+  t.inc(1)
+  assert s == t
+
 block mpairsTableTest1:
   var t = initTable[string, int]()
   t["a"] = 1
diff --git a/tests/generics/tstatictalias.nim b/tests/generics/tstatictalias.nim
new file mode 100644
index 000000000..98751b8cb
--- /dev/null
+++ b/tests/generics/tstatictalias.nim
@@ -0,0 +1,20 @@
+discard """
+  output: '''G:0,1:0.1
+G:0,1:0.1
+H:1:0.1'''
+"""
+
+type
+  G[i,j:static[int]] = object
+    v:float
+  H[j:static[int]] = G[0,j]
+proc p[i,j:static[int]](x:G[i,j]) = echo "G:",i,",",j,":",x.v
+proc q[j:static[int]](x:H[j]) = echo "H:",j,":",x.v
+
+var
+  g0 = G[0,1](v: 0.1)
+  h0:H[1] = g0
+p(g0)
+p(h0)
+q(h0)
+# bug #4863
diff --git a/tests/js/tconsole.nim b/tests/js/tconsole.nim
new file mode 100644
index 000000000..f6da71c20
--- /dev/null
+++ b/tests/js/tconsole.nim
@@ -0,0 +1,13 @@
+discard """
+  output: '''Hello, console
+1 2 3
+1 'hi' 1.1'''
+"""
+
+# This file tests the JavaScript console
+
+import jsconsole
+
+console.log("Hello, console")
+console.log(1, 2, 3)
+console.log(1, "hi", 1.1)
\ No newline at end of file
diff --git a/tests/macros/tdump.nim b/tests/macros/tdump.nim
new file mode 100644
index 000000000..e4c14dc6b
--- /dev/null
+++ b/tests/macros/tdump.nim
@@ -0,0 +1,13 @@
+discard """
+  output: '''x = 10
+x + y = 30
+'''
+"""
+
+import future
+
+let
+  x = 10
+  y = 20
+dump x
+dump(x + y)
\ No newline at end of file
diff --git a/tests/osproc/tafalse.nim b/tests/osproc/tafalse.nim
new file mode 100644
index 000000000..24fd4fb2e
--- /dev/null
+++ b/tests/osproc/tafalse.nim
@@ -0,0 +1,3 @@
+# 'tafalse.nim' to ensure it is compiled before texitcode.nim
+import system
+quit(QuitFailure)
diff --git a/tests/osproc/texitcode.nim b/tests/osproc/texitcode.nim
new file mode 100644
index 000000000..1e83658c2
--- /dev/null
+++ b/tests/osproc/texitcode.nim
@@ -0,0 +1,18 @@
+discard """
+  file: "texitcode.nim"
+  output: ""
+"""
+import osproc, os
+
+const filename = when defined(Windows): "tafalse.exe" else: "tafalse"
+let dir = getCurrentDir() / "tests" / "osproc"
+doAssert fileExists(dir / filename)
+
+var p = startProcess(filename, dir)
+doAssert(waitForExit(p) == QuitFailure)
+
+p = startProcess(filename, dir)
+var running = true
+while running:
+  running = running(p)
+doAssert(waitForExit(p) == QuitFailure)
diff --git a/tests/osproc/tworkingdir.nim b/tests/osproc/tworkingdir.nim
new file mode 100644
index 000000000..84ba3375c
--- /dev/null
+++ b/tests/osproc/tworkingdir.nim
@@ -0,0 +1,16 @@
+discard """
+  file: "tworkingdir.nim"
+  output: ""
+"""
+
+import osproc, os
+when defined(windows):
+  # Windows don't have this issue, so we won't test it.
+  discard
+else:
+  let dir1 = getCurrentDir()
+  var process = startProcess("/usr/bin/env", "/usr/bin", ["true"])
+  let dir2 = getCurrentDir()
+  discard process.waitForExit()
+  process.close()
+  doAssert(dir1 == dir2, $dir1 & " != " & $dir2)
diff --git a/tests/stdlib/tgetfileinfo.nim b/tests/stdlib/tgetfileinfo.nim
index 8a0538a5f..1c897b702 100644
--- a/tests/stdlib/tgetfileinfo.nim
+++ b/tests/stdlib/tgetfileinfo.nim
@@ -1,5 +1,5 @@
 discard """
-  output: ""
+  output: "pcDir\npcFile\npcLinkToDir\npcLinkToFile\n"
 """
 
 import os, strutils
@@ -93,4 +93,42 @@ proc testGetFileInfo =
       discard
       #echo("Handle : Invalid File : Success")
 
+  # Test kind for files, directories and symlinks.
+  block:
+    let
+      tmp = getTempDir()
+      dirPath      = tmp / "test-dir"
+      filePath     = tmp / "test-file"
+      linkDirPath  = tmp / "test-link-dir"
+      linkFilePath = tmp / "test-link-file"
+
+    createDir(dirPath)
+    writeFile(filePath, "")
+    when defined(posix):
+      createSymlink(dirPath, linkDirPath)
+      createSymlink(filePath, linkFilePath)
+
+    let
+      dirInfo = getFileInfo(dirPath)
+      fileInfo = getFileInfo(filePath)
+    when defined(posix):
+      let
+        linkDirInfo = getFileInfo(linkDirPath, followSymlink = false)
+        linkFileInfo = getFileInfo(linkFilePath, followSymlink = false)
+
+    echo dirInfo.kind
+    echo fileInfo.kind
+    when defined(posix):
+      echo linkDirInfo.kind
+      echo linkFileInfo.kind
+    else:
+      echo pcLinkToDir
+      echo pcLinkToFile
+
+    removeDir(dirPath)
+    removeFile(filePath)
+    when defined(posix):
+      removeFile(linkDirPath)
+      removeFile(linkFilePath)
+
 testGetFileInfo()
diff --git a/tests/stdlib/ttime.nim b/tests/stdlib/ttime.nim
index 3ab287c4e..065009535 100644
--- a/tests/stdlib/ttime.nim
+++ b/tests/stdlib/ttime.nim
@@ -140,4 +140,27 @@ doAssert initInterval(months = 13) == initInterval(months = 1, years = 1)
 # Bug with adding a day to a Time
 let day = 24.hours
 let tomorrow = getTime() + day
-doAssert tomorrow - getTime() == 60*60*24
\ No newline at end of file
+doAssert tomorrow - getTime() == 60*60*24
+
+doAssert milliseconds(1000 * 60) == minutes(1)
+doAssert milliseconds(1000 * 60 * 60) == hours(1)
+doAssert milliseconds(1000 * 60 * 60 * 24) == days(1)
+doAssert seconds(60 * 60) == hours(1)
+doAssert seconds(60 * 60 * 24) == days(1)
+doAssert seconds(60 * 60 + 65) == (hours(1) + minutes(1) + seconds(5))
+
+# Bug with parse not setting DST properly if the current local DST differs from
+# the date being parsed. Need to test parse dates both in and out of DST. We
+# are testing that be relying on the fact that tranforming a TimeInfo to a Time
+# and back again will correctly set the DST value. With the incorrect parse
+# behavior this will introduce a one hour offset from the named time and the
+# parsed time if the DST value differs between the current time and the date we
+# are parsing.
+#
+# Unfortunately these tests depend on the locale of the system in which they
+# are run. They will not be meaningful when run in a locale without DST. They
+# also assume that Jan. 1 and Jun. 1 will have differing isDST values.
+let dstT1 = parse("2016-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss")
+let dstT2 = parse("2016-06-01 00:00:00", "yyyy-MM-dd HH:mm:ss")
+doAssert dstT1 == getLocalTime(toTime(dstT1))
+doAssert dstT2 == getLocalTime(toTime(dstT2))
diff --git a/tests/template/tconfusinglocal.nim b/tests/template/tconfusinglocal.nim
new file mode 100644
index 000000000..9b2cdc954
--- /dev/null
+++ b/tests/template/tconfusinglocal.nim
@@ -0,0 +1,13 @@
+
+# bug #4875
+type Bar = object
+    mFoo: int
+
+template foo(a: Bar): int = a.mFoo
+
+proc main =
+    let foo = 5 # Rename this to smth else to make it work
+    var b: Bar
+    echo b.foo
+
+main()
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 3ed2f2196..809425653 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -115,6 +115,12 @@ proc dllTests(r: var TResults, cat: Category, options: string) =
 # ------------------------------ GC tests -------------------------------------
 
 proc gcTests(r: var TResults, cat: Category, options: string) =
+  template testWithNone(filename: untyped) =
+    testSpec r, makeTest("tests/gc" / filename, options &
+                  " --gc:none", cat, actionRun)
+    testSpec r, makeTest("tests/gc" / filename, options &
+                  " -d:release --gc:none", cat, actionRun)
+
   template testWithoutMs(filename: untyped) =
     testSpec r, makeTest("tests/gc" / filename, options, cat, actionRun)
     testSpec r, makeTest("tests/gc" / filename, options &
@@ -144,6 +150,7 @@ proc gcTests(r: var TResults, cat: Category, options: string) =
   test "gcleak"
   test "gcleak2"
   test "gctest"
+  testWithNone "gctest"
   test "gcleak3"
   test "gcleak4"
   # Disabled because it works and takes too long to run:
@@ -375,8 +382,14 @@ proc `&.?`(a, b: string): string =
 proc `&?.`(a, b: string): string =
   # candidate for the stdlib?
   result = if a.endswith(b): a else: a & b
+  
+proc processSingleTest(r: var TResults, cat: Category, options, test: string) =
+  let test = "tests" & DirSep &.? cat.string / test
+
+  if existsFile(test): testSpec r, makeTest(test, options, cat)
+  else: echo "[Warning] - ", test, " test does not exist"
 
-proc processCategory(r: var TResults, cat: Category, options: string, fileGlob: string = "t*.nim") =
+proc processCategory(r: var TResults, cat: Category, options: string) =
   case cat.string.normalize
   of "rodfiles":
     when false: compileRodFiles(r, cat, options)
@@ -417,5 +430,5 @@ proc processCategory(r: var TResults, cat: Category, options: string, fileGlob:
     # We can't test it because it depends on a third party.
     discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.
   else:
-    for name in os.walkFiles("tests" & DirSep &.? cat.string / fileGlob):
+    for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
       testSpec r, makeTest(name, options, cat)
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 74ac58927..2734742f4 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -445,7 +445,7 @@ proc main() =
     let (dir, file) = splitPath(p.key.string)
     let (_, subdir) = splitPath(dir)
     var cat = Category(subdir)
-    processCategory(r, cat, p.cmdLineRest.string, file)
+    processSingleTest(r, cat, p.cmdLineRest.string, file)
   of "html":
     var commit = 0
     discard parseInt(p.cmdLineRest.string, commit)
diff --git a/tests/vm/tgorge.bat b/tests/vm/tgorge.bat
new file mode 100644
index 000000000..24d365842
--- /dev/null
+++ b/tests/vm/tgorge.bat
@@ -0,0 +1 @@
+@echo gorge test
\ No newline at end of file
diff --git a/tests/vm/tgorge.nim b/tests/vm/tgorge.nim
new file mode 100644
index 000000000..596f5d667
--- /dev/null
+++ b/tests/vm/tgorge.nim
@@ -0,0 +1,12 @@
+import os
+
+template getScriptDir(): string =
+  parentDir(instantiationInfo(-1, true).filename)
+
+const
+  execName = when defined(windows): "tgorge.bat" else: "sh tgorge.sh"
+  relOutput = gorge(execName)
+  absOutput = gorge(getScriptDir() / execName)
+
+doAssert relOutput == "gorge test"
+doAssert absOutput == "gorge test"
diff --git a/tests/vm/tgorge.sh b/tests/vm/tgorge.sh
new file mode 100644
index 000000000..ba47afeae
--- /dev/null
+++ b/tests/vm/tgorge.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "gorge test"
\ No newline at end of file
diff --git a/tools/finish.nim b/tools/finish.nim
new file mode 100644
index 000000000..8b9acfc56
--- /dev/null
+++ b/tools/finish.nim
@@ -0,0 +1,165 @@
+
+# -------------- post unzip steps ---------------------------------------------
+
+import strutils, os, osproc
+
+when defined(windows):
+  import registry
+
+  proc askBool(m: string): bool =
+    stdout.write m
+    while true:
+      let answer = stdin.readLine().normalize
+      case answer
+      of "y", "yes":
+        return true
+      of "n", "no":
+        return false
+      else:
+        echo "Please type 'y' or 'n'"
+
+  proc askNumber(m: string; a, b: int): int =
+    stdout.write m
+    stdout.write " [" & $a & ".." & $b & "] "
+    while true:
+      let answer = stdin.readLine()
+      try:
+        result = parseInt answer
+        if result < a or result > b:
+          raise newException(ValueError, "number out of range")
+        break
+      except ValueError:
+        echo "Please type in a number between ", a, " and ", b
+
+  proc patchConfig(mingw: string) =
+    const
+      cfgFile = "config/nim.cfg"
+      lookFor = """#gcc.path = r"$nim\dist\mingw\bin""""
+      replacePattern = """gcc.path = r"$1""""
+    try:
+      let cfg = readFile(cfgFile)
+      let newCfg = cfg.replace(lookFor, replacePattern % mingw)
+      if newCfg == cfg:
+        echo "Could not patch 'config/nim.cfg' [Error]"
+        echo "Reason: patch substring not found:"
+        echo lookFor
+      else:
+        writeFile(cfgFile, newCfg)
+    except IOError:
+      echo "Could not access 'config/nim.cfg' [Error]"
+
+  proc addToPathEnv(e: string) =
+    let p = getUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER)
+    let x = if e.contains(Whitespace): "\"" & e & "\"" else: e
+    setUnicodeValue(r"Environment", "Path", p & ";" & x, HKEY_CURRENT_USER)
+
+  proc createShortcut(src, dest: string; icon = "") =
+    var cmd = "bin\\makelink.exe \"" & src & "\" \"\" \"" & dest &
+         ".lnk\" \"\" 1 \"" & splitFile(src).dir & "\""
+    if icon.len != 0:
+      cmd.add " \"" & icon & "\" 0"
+    discard execShellCmd(cmd)
+
+  proc createStartMenuEntry() =
+    let appdata = getEnv("APPDATA")
+    if appdata.len == 0: return
+    let dest = appdata & r"\Microsoft\Windows\Start Menu\Programs\Nim-" &
+               NimVersion
+    if dirExists(dest): return
+    if askBool("Would like to add Nim-" & NimVersion &
+               " to your start menu? (y/n) "):
+      createDir(dest)
+      createShortcut(getCurrentDir() / "tools" / "start.bat", dest / "Nim",
+                     getCurrentDir() / r"icons\nim.ico")
+      if fileExists("doc/overview.html"):
+        createShortcut(getCurrentDir() / "doc" / "html" / "overview.html",
+                       dest / "Overview")
+      if dirExists(r"dist\aporia-0.4.0"):
+        createShortcut(getCurrentDir() / r"dist\aporia-0.4.0\bin\aporia.exe",
+                       dest / "Aporia")
+
+  proc checkGccArch(mingw: string): bool =
+    let gccExe = mingw / r"gcc.exe"
+    if fileExists(gccExe):
+      try:
+        let arch = execProcess(gccExe, ["-dumpmachine"], nil, {poStdErrToStdOut,
+                                                               poUsePath})
+        when hostCPU == "i386":
+          result = arch.startsWith("i686-")
+        elif hostCPU == "amd64":
+          result = arch.startsWith("x86_64-")
+        else:
+          {.error: "Unknown CPU for Windows.".}
+      except OSError, IOError:
+        result = false
+
+  proc tryDirs(incompat: var seq[string]; dirs: varargs[string]): string =
+    let bits = $(sizeof(pointer)*8)
+    for d in dirs:
+      if dirExists d:
+        let x = expandFilename(d / "bin")
+        if checkGccArch(x): return x
+        else: incompat.add x
+      elif dirExists(d & bits):
+        let x = expandFilename((d & bits) / "bin")
+        if checkGccArch(x): return x
+        else: incompat.add x
+
+proc main() =
+  when defined(windows):
+    let desiredPath = expandFilename(getCurrentDir() / "bin")
+    let p = getUnicodeValue(r"Environment", "Path",
+      HKEY_CURRENT_USER)
+    var alreadyInPath = false
+    var mingWchoices: seq[string] = @[]
+    var incompat: seq[string] = @[]
+    for x in p.split(';'):
+      let y = expandFilename(if x[0] == '"' and x[^1] == '"':
+                  substr(x, 1, x.len-2) else: x)
+      if y == desiredPath: alreadyInPath = true
+      if y.toLowerAscii.contains("mingw"):
+        if dirExists(y):
+          if checkGccArch(y): mingWchoices.add y
+          else: incompat.add y
+
+    if alreadyInPath:
+      echo "bin/nim.exe is already in your PATH [Skipping]"
+    else:
+      if askBool("nim.exe is not in your PATH environment variable.\n" &
+          "Should it be added permanently? (y/n) "):
+        addToPathEnv(desiredPath)
+    if mingWchoices.len == 0:
+      # No mingw in path, so try a few locations:
+      let alternative = tryDirs(incompat, "dist/mingw", "../mingw", r"C:\mingw")
+      if alternative.len == 0:
+        if incompat.len > 0:
+          echo "The following *incompatible* MingW installations exist"
+          for x in incompat: echo x
+        echo "No compatible MingW candidates found " &
+             "in the standard locations [Error]"
+      else:
+        if askBool("Found a MingW directory that is not in your PATH.\n" &
+                   alternative &
+                   "\nShould it be added to your PATH permanently? (y/n) "):
+          addToPathEnv(alternative)
+        elif askBool("Do you want to patch Nim's config to use this? (y/n) "):
+          patchConfig(alternative)
+    elif mingWchoices.len == 1:
+      if askBool("MingW installation found at " & mingWchoices[0] & "\n" &
+         "Do you want to patch Nim's config to use this?\n" &
+         "(Not required since it's in your PATH!) (y/n) "):
+        patchConfig(mingWchoices[0])
+    else:
+      echo "Multiple MingW installations found: "
+      for i in 0..high(mingWchoices):
+        echo "[", i, "] ", mingWchoices[i]
+      if askBool("Do you want to patch Nim's config to use one of these? (y/n) "):
+        let idx = askNumber("Which one do you want to use for Nim? ",
+            1, len(mingWchoices))
+        patchConfig(mingWchoices[idx-1])
+    createStartMenuEntry()
+  else:
+    echo("Add ", getCurrentDir(), "/bin to your PATH...")
+
+when isMainModule:
+  main()
diff --git a/tools/niminst/buildbat.tmpl b/tools/niminst/buildbat.tmpl
index 2a8da144d..278b6caea 100644
--- a/tools/niminst/buildbat.tmpl
+++ b/tools/niminst/buildbat.tmpl
@@ -1,5 +1,5 @@
 #? stdtmpl(subsChar='?') | standard
-#proc generateBuildBatchScript(c: ConfigData, winIndex, cpuIndex: int): string = 
+#proc generateBuildBatchScript(c: ConfigData, winIndex, cpuIndex: int): string =
 #  result = "@echo off\nREM Generated by niminst\n"
 SET CC=gcc
 SET LINKER=gcc
@@ -23,8 +23,8 @@ CALL %CC% %COMP_FLAGS% -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")}
 IF ERRORLEVEL 1 (GOTO:END)
 #    end for
 
-ECHO %LINKER% -o ?{"%BIN_DIR%"\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
-CALL %LINKER% -o ?{"%BIN_DIR%"\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
+ECHO %LINKER% -o ?{"%BIN_DIR%"\toLowerAscii(c.name)}.exe ?linkCmd %LINK_FLAGS%
+CALL %LINKER% -o ?{"%BIN_DIR%"\toLowerAscii(c.name)}.exe ?linkCmd %LINK_FLAGS%
 
 #  end block
 
diff --git a/tools/niminst/buildsh.tmpl b/tools/niminst/buildsh.tmpl
index 220ecdb7f..f82fc0fee 100644
--- a/tools/niminst/buildsh.tmpl
+++ b/tools/niminst/buildsh.tmpl
@@ -94,6 +94,9 @@ case $uos in
     myos="haiku"
     LINK_FLAGS="$LINK_FLAGS -lroot -lnetwork"
     ;;
+  *mingw* )
+    myos="windows"
+    ;;
   *)
     echo 2>&1 "Error: unknown operating system: $uos"
     exit 1
@@ -144,7 +147,7 @@ case $myos in
     $CC $COMP_FLAGS -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")}
 #        add(linkCmd, " \\\n" & changeFileExt(f, "o"))
 #      end for
-    $LINKER -o ?{"$binDir/" & toLower(c.name)} ?linkCmd $LINK_FLAGS
+    $LINKER -o ?{"$binDir/" & toLowerAscii(c.name)} ?linkCmd $LINK_FLAGS
     ;;
 #    end for
   *)
diff --git a/tools/niminst/debcreation.nim b/tools/niminst/debcreation.nim
index 36b2a29ec..0ecea132f 100644
--- a/tools/niminst/debcreation.nim
+++ b/tools/niminst/debcreation.nim
@@ -148,7 +148,7 @@ proc prepDeb*(packName, version, mtnName, mtnEmail, shortDesc, desc: string,
   ## binaries/config/docs/lib: files relative to nim's root, that need to
   ##   be installed.
 
-  let pkgName = packName.toLower()
+  let pkgName = packName.toLowerAscii()
 
   var workingDir = getTempDir() / "niminst" / "deb"
   var upstreamSource = (pkgName & "-" & version)
@@ -168,7 +168,7 @@ proc prepDeb*(packName, version, mtnName, mtnEmail, shortDesc, desc: string,
   echo("Creating necessary files in debian/")
   createDir(workingDir / upstreamSource / "debian")
 
-  template writeDebian(f, s: string): expr =
+  template writeDebian(f, s: string) =
     writeFile(workingDir / upstreamSource / "debian" / f, s)
 
   var controlFile = createControl(pkgName, makeMtn(mtnName, mtnEmail),
diff --git a/tools/niminst/deinstall.tmpl b/tools/niminst/deinstall.tmpl
index 3cdfbf45d..bba310f76 100644
--- a/tools/niminst/deinstall.tmpl
+++ b/tools/niminst/deinstall.tmpl
@@ -1,7 +1,7 @@
 #? stdtmpl(subsChar='?') | standard
 #proc generateDeinstallScript(c: ConfigData): string =
 #  result = "#! /bin/sh\n# Generated by niminst\n"
-#  var proj = c.name.toLower
+#  var proj = c.name.toLowerAscii
 
 if [ $# -eq 1 ] ; then
   case $1 in
diff --git a/tools/niminst/install.tmpl b/tools/niminst/install.tmpl
index 3f17840a8..d72b132ef 100644
--- a/tools/niminst/install.tmpl
+++ b/tools/niminst/install.tmpl
@@ -1,7 +1,7 @@
 #? stdtmpl(subsChar = '?') | standard
 #proc generateInstallScript(c: ConfigData): string =
 #  result = "#! /bin/sh\n# Generated by niminst\n"
-#  var proj = c.name.toLower
+#  var proj = c.name.toLowerAscii
 
 ## Current directory you start script from
 BASE_DIR=$(pwd)
diff --git a/tools/niminst/makefile.tmpl b/tools/niminst/makefile.tmpl
index 5c95ccda9..ce2db1c48 100644
--- a/tools/niminst/makefile.tmpl
+++ b/tools/niminst/makefile.tmpl
@@ -157,7 +157,7 @@ endif
 %.o: %.c
 	$(CC) $(COMP_FLAGS) -Ic_code -c $< -o $@
 
-?{"$(binDir)/" & toLower(c.name)}: $(oFiles)
+?{"$(binDir)/" & toLowerAscii(c.name)}: $(oFiles)
 	@mkdir -p $(binDir)
 	$(LINKER) -o $@ $^ $(LINK_FLAGS)
 	@echo "SUCCESS"
@@ -165,4 +165,4 @@ endif
 .PHONY: clean
 
 clean:
-	rm -f $(oFiles) ?{"$(binDir)/" & toLower(c.name)}
+	rm -f $(oFiles) ?{"$(binDir)/" & toLowerAscii(c.name)}
diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim
index 01efa88d4..e0b8ad9b3 100644
--- a/tools/niminst/niminst.nim
+++ b/tools/niminst/niminst.nim
@@ -313,7 +313,7 @@ proc parseIniFile(c: var ConfigData) =
       of cfgSectionStart:
         section = normalize(k.section)
       of cfgKeyValuePair:
-        var v = k.value % c.vars
+        var v = `%`(k.value, c.vars, {useEnvironment, useEmpty})
         c.vars[k.key] = v
 
         case section
@@ -552,7 +552,7 @@ proc srcdist(c: var ConfigData) =
 # --------------------- generate inno setup -----------------------------------
 proc setupDist(c: var ConfigData) =
   let scrpt = generateInnoSetup(c)
-  let n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version]
+  let n = "build" / "install_$#_$#.iss" % [toLowerAscii(c.name), c.version]
   writeFile(n, scrpt, "\13\10")
   when defined(windows):
     if c.innosetup.path.len == 0:
@@ -569,7 +569,7 @@ proc setupDist(c: var ConfigData) =
 # --------------------- generate NSIS setup -----------------------------------
 proc setupDist2(c: var ConfigData) =
   let scrpt = generateNsisSetup(c)
-  let n = "build" / "install_$#_$#.nsi" % [toLower(c.name), c.version]
+  let n = "build" / "install_$#_$#.nsi" % [toLowerAscii(c.name), c.version]
   writeFile(n, scrpt, "\13\10")
   when defined(windows):
     if c.nsisSetup.path.len == 0:
@@ -586,7 +586,7 @@ proc setupDist2(c: var ConfigData) =
 # ------------------ generate ZIP file ---------------------------------------
 when haveZipLib:
   proc zipDist(c: var ConfigData) =
-    var proj = toLower(c.name) & "-" & c.version
+    var proj = toLowerAscii(c.name) & "-" & c.version
     var n = "$#.zip" % proj
     if c.outdir.len == 0: n = "build" / n
     else: n = c.outdir / n
@@ -617,49 +617,64 @@ when haveZipLib:
     else:
       quit("Cannot open for writing: " & n)
 
-proc xzDist(c: var ConfigData) =
-  let proj = toLower(c.name) & "-" & c.version
-  var n = "$#.tar.xz" % proj
+proc xzDist(c: var ConfigData; windowsZip=false) =
+  let proj = toLowerAscii(c.name) & "-" & c.version
   let tmpDir = if c.outdir.len == 0: "build" else: c.outdir
 
-  template processFile(z, dest, src) =
-    let s = src
-    let d = dest
-    echo "Copying ", s, " to ", tmpDir / d
-    let destdir = tmpdir / d.splitFile.dir
-    if not dirExists(destdir): createDir(destdir)
-    copyFileWithPermissions(s, tmpDir / d)
-
-  processFile(z, proj / buildBatFile32, "build" / buildBatFile32)
-  processFile(z, proj / buildBatFile64, "build" / buildBatFile64)
-  processFile(z, proj / buildShFile, "build" / buildShFile)
-  processFile(z, proj / makeFile, "build" / makeFile)
-  processFile(z, proj / installShFile, installShFile)
-  processFile(z, proj / deinstallShFile, deinstallShFile)
-  for f in walkFiles(c.libpath / "lib/*.h"):
-    processFile(z, proj / "c_code" / extractFilename(f), f)
-  for osA in 1..c.oses.len:
-    for cpuA in 1..c.cpus.len:
-      var dir = buildDir(osA, cpuA)
-      for k, f in walkDir("build" / dir):
-        if k == pcFile: processFile(z, proj / dir / extractFilename(f), f)
+  proc processFile(destFile, src: string) =
+    let dest = tmpDir / destFile
+    echo "Copying ", src, " to ", dest
+    if not existsFile(src):
+      echo "[Warning] Source file doesn't exist: ", src
+    let destDir = dest.splitFile.dir
+    if not dirExists(destDir): createDir(destDir)
+    copyFileWithPermissions(src, dest)
+
+  if not windowsZip and not existsFile("build" / buildBatFile32):
+    quit("No C sources found in ./build/, please build by running " &
+         "./koch csource -d:release.")
+
+  if not windowsZip:
+    processFile(proj / buildBatFile32, "build" / buildBatFile32)
+    processFile(proj / buildBatFile64, "build" / buildBatFile64)
+    processFile(proj / buildShFile, "build" / buildShFile)
+    processFile(proj / makeFile, "build" / makeFile)
+    processFile(proj / installShFile, installShFile)
+    processFile(proj / deinstallShFile, deinstallShFile)
+    for f in walkFiles(c.libpath / "lib/*.h"):
+      processFile(proj / "c_code" / extractFilename(f), f)
+    for osA in 1..c.oses.len:
+      for cpuA in 1..c.cpus.len:
+        var dir = buildDir(osA, cpuA)
+        for k, f in walkDir("build" / dir):
+          if k == pcFile: processFile(proj / dir / extractFilename(f), f)
+  else:
+    for f in items(c.cat[fcWinBin]):
+      let filename = f.extractFilename
+      processFile(proj / "bin" / filename, f)
 
-  for cat in items({fcConfig..fcOther, fcUnix, fcNimble}):
+  let osSpecific = if windowsZip: fcWindows else: fcUnix
+  for cat in items({fcConfig..fcOther, osSpecific, fcNimble}):
     echo("Current category: ", cat)
-    for f in items(c.cat[cat]): processFile(z, proj / f, f)
+    for f in items(c.cat[cat]): processFile(proj / f, f)
 
   # Copy the .nimble file over
   let nimbleFile = c.nimblePkgName & ".nimble"
-  processFile(z, proj / nimbleFile, nimbleFile)
+  processFile(proj / nimbleFile, nimbleFile)
 
   when true:
     let oldDir = getCurrentDir()
     setCurrentDir(tmpDir)
     try:
-      if execShellCmd("XZ_OPT=-9 gtar Jcf $1.tar.xz $1 --exclude=.DS_Store" % proj) != 0:
-        # try old 'tar' without --exclude feature:
-        if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
+      if windowsZip:
+        if execShellCmd("7z a -tzip $1.zip $1" % proj) != 0:
           echo("External program failed")
+      else:
+        if execShellCmd("XZ_OPT=-9 gtar Jcf $1.tar.xz $1 --exclude=.DS_Store" %
+                        proj) != 0:
+          # try old 'tar' without --exclude feature:
+          if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
+            echo("External program failed")
     finally:
       setCurrentDir(oldDir)
 
@@ -677,11 +692,11 @@ proc debDist(c: var ConfigData) =
   echo("Copying source to tmp/niminst/deb/")
   var currentSource = getCurrentDir()
   var workingDir = getTempDir() / "niminst" / "deb"
-  var upstreamSource = (c.name.toLower() & "-" & c.version)
+  var upstreamSource = (c.name.toLowerAscii() & "-" & c.version)
 
   createDir(workingDir / upstreamSource)
 
-  template copyNimDist(f, dest: string): stmt =
+  template copyNimDist(f, dest: string) =
     createDir((workingDir / upstreamSource / dest).splitFile.dir)
     copyFile(currentSource / f, workingDir / upstreamSource / dest)
 
@@ -725,10 +740,7 @@ if actionCSource in c.actions:
 if actionScripts in c.actions:
   writeInstallScripts(c)
 if actionZip in c.actions:
-  when haveZipLib:
-    zipDist(c)
-  else:
-    quit("libzip is not installed")
+  xzDist(c, true)
 if actionXz in c.actions:
   xzDist(c)
 if actionDeb in c.actions:
diff --git a/tools/niminst/nsis.tmpl b/tools/niminst/nsis.tmpl
index 639a01b6b..95d4652e3 100644
--- a/tools/niminst/nsis.tmpl
+++ b/tools/niminst/nsis.tmpl
@@ -202,7 +202,7 @@
     ; Shortcuts
     #  if d.len >= 6:
     #    let startMenuEntry = d[5]
-    #    let e = splitFile(startMenuEntry).name.capitalize
+    #    let e = splitFile(startMenuEntry).name.capitalizeAscii
       !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
         CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{e}.lnk" "$INSTDIR\?dir\?{startMenuEntry.toWin}"
       !insertmacro MUI_STARTMENU_WRITE_END
diff --git a/tools/nimweb.nim b/tools/nimweb.nim
index 65af67216..9a21a0fb5 100644
--- a/tools/nimweb.nim
+++ b/tools/nimweb.nim
@@ -29,7 +29,7 @@ type
   TRssItem = object
     year, month, day, title, url, content: string
   TAction = enum
-    actAll, actOnlyWebsite, actPdf, actJson2
+    actAll, actOnlyWebsite, actPdf, actJson2, actOnlyDocs
 
   Sponsor = object
     logo: string
@@ -72,7 +72,7 @@ include "website.tmpl"
 # ------------------------- configuration file -------------------------------
 
 const
-  version = "0.7"
+  version = "0.8"
   usage = "nimweb - Nim Website Generator Version " & version & """
 
   (c) 2015 Andreas Rumpf
@@ -85,11 +85,13 @@ Options:
   -v, --version       shows the version
   --website           only build the website, not the full documentation
   --pdf               build the PDF version of the documentation
+  --json2             build JSON of the documentation
+  --onlyDocs          build only the documentation
 Compile_options:
   will be passed to the Nim compiler
 """
 
-  rYearMonthDay = r"(\d{4})_(\d{2})_(\d{2})"
+  rYearMonthDay = r"on\s+(\d{2})\/(\d{2})\/(\d{4})"
   rssUrl = "http://nim-lang.org/news.xml"
   rssNewsUrl = "http://nim-lang.org/news.html"
   activeSponsors = "web/sponsors.csv"
@@ -157,6 +159,7 @@ proc parseCmdLine(c: var TConfigData) =
       of "website": action = actOnlyWebsite
       of "pdf": action = actPdf
       of "json2": action = actJson2
+      of "onlydocs": action = actOnlyDocs
       of "googleanalytics":
         c.gaId = val
         c.nimArgs.add("--doc.googleAnalytics:" & val & " ")
@@ -315,6 +318,7 @@ proc buildDoc(c: var TConfigData, destPath: string) =
   exec(findNim() & " buildIndex -o:$1/theindex.html $1" % [destPath])
 
 proc buildPdfDoc(c: var TConfigData, destPath: string) =
+  createDir(destPath)
   if os.execShellCmd("pdflatex -version") != 0:
     echo "pdflatex not found; no PDF documentation generated"
   else:
@@ -347,6 +351,7 @@ proc buildAddDoc(c: var TConfigData, destPath: string) =
 proc parseNewsTitles(inputFilename: string): seq[TRssItem] =
   # Goes through each news file, returns its date/title.
   result = @[]
+  var matches: array[3, string]
   let reYearMonthDay = re(rYearMonthDay)
   for kind, path in walkDir(inputFilename):
     let (dir, name, ext) = path.splitFile
@@ -354,8 +359,8 @@ proc parseNewsTitles(inputFilename: string): seq[TRssItem] =
       let content = readFile(path)
       let title = content.splitLines()[0]
       let urlPath = "news/" & name & ".html"
-      if name =~ reYearMonthDay:
-        result.add(TRssItem(year: matches[0], month: matches[1], day: matches[2],
+      if content.find(reYearMonthDay, matches) >= 0:
+        result.add(TRssItem(year: matches[2], month: matches[1], day: matches[0],
           title: title, url: "http://nim-lang.org/" & urlPath,
           content: content))
   result.reverse()
@@ -501,11 +506,19 @@ proc buildWebsite(c: var TConfigData) =
 proc main(c: var TConfigData) =
   buildWebsite(c)
   buildJS("web/upload")
-  buildAddDoc(c, "web/upload")
-  buildDocSamples(c, "web/upload")
-  buildDoc(c, "web/upload")
-  buildDocSamples(c, "doc")
-  buildDoc(c, "doc")
+  const docup = "web/upload/" & NimVersion
+  createDir(docup)
+  buildAddDoc(c, docup)
+  buildDocSamples(c, docup)
+  buildDoc(c, docup)
+  createDir("doc/html")
+  buildDocSamples(c, "doc/html")
+  buildDoc(c, "doc/html")
+
+proc onlyDocs(c: var TConfigData) =
+  createDir("doc/html")
+  buildDocSamples(c, "doc/html")
+  buildDoc(c, "doc/html")
 
 proc json2(c: var TConfigData) =
   const destPath = "web/json2"
@@ -526,6 +539,7 @@ parseCmdLine(c)
 parseIniFile(c)
 case action
 of actOnlyWebsite: buildWebsite(c)
-of actPdf: buildPdfDoc(c, "doc")
+of actPdf: buildPdfDoc(c, "doc/pdf")
+of actOnlyDocs: onlyDocs(c)
 of actAll: main(c)
 of actJson2: json2(c)
diff --git a/tools/noprefix.nim b/tools/noprefix.nim
deleted file mode 100644
index d16c2b520..000000000
--- a/tools/noprefix.nim
+++ /dev/null
@@ -1,32 +0,0 @@
-# strip those silly GTK/ATK prefixes...
-
-import
-  expandimportc, os
-
-const
-  filelist = [
-    ("sdl/sdl", "sdl"),
-    ("sdl/sdl_net", "sdl"),
-    ("sdl/sdl_gfx", "sdl"),
-    ("sdl/sdl_image", "sdl"),
-    ("sdl/sdl_mixer_nosmpeg", "sdl"),
-    ("sdl/sdl_mixer", "sdl"),
-    ("sdl/sdl_ttf", "sdl"),
-    ("sdl/smpeg", "sdl"),
-
-    ("libcurl", "curl"),
-    ("mysql", "mysql"),
-    ("postgres", ""),
-    ("sqlite3", "sqlite3"),
-
-    ("pcre/pcre", "pcre")
-  ]
-
-proc createDirs =
-  createDir("lib/newwrap/sdl")
-  createDir("lib/newwrap/pcre")
-
-for filename, prefix in items(filelist):
-  var f = addFileExt(filename, "nim")
-  main("lib/wrappers" / f, "lib/newwrap" / f, prefix)
-
diff --git a/start.bat b/tools/start.bat
index 685932c47..a4475fac7 100644
--- a/start.bat
+++ b/tools/start.bat
@@ -1,6 +1,8 @@
 @echo off

 REM COLOR 0A

-SET NIMPATH=%~dp0

+SET NIMPATH=%~dp0\..

 SET PATH=%NIMPATH%\bin;%NIMPATH%\dist\mingw\bin;%PATH%

-cmd

+cd %NIMPATH%

+cmd 

+

 

diff --git a/web/download.rst b/web/download.rst
index cf0841577..c388dd132 100644
--- a/web/download.rst
+++ b/web/download.rst
@@ -3,17 +3,34 @@ Download the compiler
 
 You can download the latest version of the Nim compiler here.
 
-Binaries
---------
+Windows
+-------
 
-Right now binaries are only provided for Windows. You can download
-an installer for both 32 bit and 64 bit versions of Windows below. These
+Zips
+%%%%
+
+We now encourage you to install via the provided zipfiles:
+
+* | 32 bit: `nim-0.15.2_x32.zip <download/nim-0.15.2_x32.zip>`_
+  | SHA-256  0f1bfb74751f55e090140a361c08e9f39f1dd03f1f0c070c061f2d5049ab9f96
+* | 64 bit: `nim-0.15.2_x64.zip <download/nim-0.15.2_x64.zip>`_
+  | SHA-256  ceea42de6ebcd41032ee51f04526dc4cf2cbb0958ca6ad2321cf21944e05f553
+
+Unzip these where you want and optionally run ``finish.exe`` to
+detect your MingW environment.
+
+Exes
+%%%%
+
+You can download an installer for both 32 bit and 64 bit versions of
+Windows below. Note that these installers have some known issues and
+so will unlikely to be provided further in the future. These
 installers have everything you need to use Nim, including a C compiler.
 
-* | 32 bit: `nim-0.15.0_x32.exe <download/nim-0.15.0_x32.exe>`_
-  | SHA-256  0ca8931e3369735bbafdf93de98a8fd0f425870f1173845e7601922a5e00c3c2
-* | 64 bit: `nim-0.15.0_x64.exe <download/nim-0.15.0_x64.exe>`_
-  | SHA-256  7bb9321cd9fb2860d36ee9b248e0202d7d4e36e2272a2f128fbce96fd4a9bfd6
+* | 32 bit: `nim-0.15.2_x32.exe <download/nim-0.15.2_x32.exe>`_
+  | SHA-256  8d648295dbd59cb315c98926a1da9f1f68773a1a2ef3d9d4c91c59387167efa3
+* | 64 bit: `nim-0.15.2_x64.exe <download/nim-0.15.2_x64.exe>`_
+  | SHA-256  8c7efc6571921c2d2e5e995f801d4229ea1de19fbdabdcba1628307bd4612392
 
 These installers also include Aporia, Nimble and other useful Nim tools to get
 you started with Nim development!
@@ -31,8 +48,8 @@ like systems.
 
 Firstly, download this archive:
 
-* | `nim-0.15.0.tar.xz (4.5MB) <download/nim-0.15.0.tar.xz>`_
-  | SHA-256  c514535050b2b2156147bbe6e23aafe07cd996b2afa2c81fa9a09e1cd8c669fb
+* | `nim-0.15.2.tar.xz (4.5MB) <download/nim-0.15.2.tar.xz>`_
+  | SHA-256  905df2316262aa2cbacae067acf45fc05c2a71c8c6fde1f2a70c927ebafcfe8a
 
 Extract the archive. Then copy the extracted files into your chosen installation
 directory, ideally somewhere in your home directory.
@@ -44,7 +61,7 @@ Now open a terminal and follow these instructions:
 ``cd ~/programs/nim``.
 * run ``sh build.sh``.
 * Add ``$your_install_dir/bin`` to your PATH.
-* To build associated tools like ``nimble`` and ``nimsuggest`` run ``nim e install_tools.nims``.
+* To build associated tools like ``nimble`` and ``nimsuggest`` run ``nim c koch && koch tools``.
 
 After restarting your terminal, you should be able to run ``nim -v``
 which should show you the version of Nim you just installed.
diff --git a/web/inactive_sponsors.csv b/web/inactive_sponsors.csv
index 929882ff4..d466f3f31 100644
--- a/web/inactive_sponsors.csv
+++ b/web/inactive_sponsors.csv
@@ -1,22 +1,28 @@
 logo, name, url, this_month, all_time, since, level
+,bogen,,0,1010,"Jul 23, 2016",1
 ,mikra,,0,400,"Apr 28, 2016",1
 ,linkmonitor,,0,180,"Jan 28, 2016",1
+,avsej,,0,110,"Jun 10, 2016",1
+,WilRubin,,0,100,"Aug 11, 2015",1
 ,"Benny Luypaert",,0,100,"Apr 10, 2016",1
 ,"Chris Heller",,0,100,"May 19, 2016",1
 ,PhilipWitte,,0,100,"Aug 5, 2016",1
 ,Boxifier,,0,75,"Apr 12, 2016",1
 ,iolloyd,,0,75,"Apr 29, 2016",1
-,WilRubin,,0,50,"Aug 11, 2015",1
 ,rb01,,0,50,"May 4, 2016",1
 ,TedSinger,,0,45,"Apr 9, 2016",1
 ,martinbbjerregaard,,0,35,"Jun 9, 2016",1
+,RationalG,,0,30,"Jun 17, 2016",1
 ,benbve,,0,30,"Jul 12, 2016",1
 ,barcharcraz,,0,25,"Jun 2, 2016",1
 ,"Landon Bass",,0,25,"Jun 7, 2016",1
 ,jimrichards,,0,25,"Jun 8, 2016",1
 ,jjzazuet,,0,25,"Jul 10, 2016",1
-,zolern,,0,20,"Apr 15, 2016",1
+,moigagoo,,0,20,"May 13, 2016",1
+,kteza1,,0,20,"Jun 10, 2016",1
+,tomkeus,,0,20,"Sep 4, 2016",1
 ,mirek,,0,15,"Apr 9, 2016",1
+,DateinAsia,,0,15,"Jul 30, 2016",1
 ,rickc,,0,15,"Jul 31, 2016",1
 ,jpkx1984,,0,13,"Jul 11, 2016",1
 ,vlkrav,,0,12,"Aug 9, 2015",1
@@ -29,7 +35,7 @@ logo, name, url, this_month, all_time, since, level
 ,Angluca,,0,10,"May 3, 2016",1
 ,calind,,0,10,"Jun 7, 2016",1
 ,goldenreign,,0,10,"Jun 10, 2016",1
-,kteza1,,0,10,"Jun 10, 2016",1
+,Blumenversand,,0,10,"Jul 21, 2016",1
 ,cinnabardk,,0,10,"Aug 6, 2016",1
 ,reddec,,0,10,"Aug 31, 2016",1
 ,niv,,0,5,"Apr 6, 2016",1
diff --git a/web/news.rst b/web/news.rst
index f819c384c..327cf6cca 100644
--- a/web/news.rst
+++ b/web/news.rst
@@ -2,102 +2,105 @@
 News
 ====
 
-`2016-09-30 Nim Version 0.15.0 released <news/2016_09_00_version_0_15_0_released.html>`_
+`2016-10-23 Nim Version 0.15.2 released <news/e028_version_0_15_2.html>`_
 ===================================
 
-`2016-09-03 Nim Community Survey results <news/2016_09_03_nim_community_survey_results.html>`_
+`2016-09-30 Nim Version 0.15.0 released <news/e027_version_0_15_0.html>`_
 ===================================
 
-`2016-08-06 BountySource Update: The Road to v1.0 <news/2016_08_06_bountysource_update_the_road_to_v10.html>`_
+`2016-09-03 Nim Community Survey results <news/e026_survey_results.html>`_
 ===================================
 
-`2016-06-23 Launching the 2016 Nim community survey <news/2016_06_23_launching_the_2016_nim_community_survey.html>`_
+`2016-08-06 BountySource Update: The Road to v1.0 <news/e025_bountysource_update.html>`_
 ===================================
 
-`2016-06-11 Version 0.14.2 released <news/2016_06_11_version_0_14_2_released.html>`_
+`2016-06-23 Launching the 2016 Nim community survey <news/e024_survey.html>`_
 ===================================
 
-`2016-06-07 Version 0.14.0 released <news/2016_06_07_version_0_14_0_released.html>`_
+`2016-06-11 Version 0.14.2 released <news/e023_version_0_14_2.html>`_
 ===================================
 
-`2016-06-04 Meet our BountySource sponsors <news/2016_06_04_meet_our_bountysource_sponsors.html>`_
+`2016-06-07 Version 0.14.0 released <news/e022_version_0_14_0.html>`_
 ===================================
 
-`2016-01-27 Nim in Action is now available! <news/2016_01_27_nim_in_action_is_now_available.html>`_
+`2016-06-04 Meet our BountySource sponsors <news/e021_meet_sponsors.html>`_
+===================================
+
+`2016-01-27 Nim in Action is now available! <news/e020_nim_in_action.html>`_
 ==================================
 
-`2016-01-18 Version 0.13.0 released <news/2016_01_18_version_0_13_0_released.html>`_
+`2016-01-18 Version 0.13.0 released <news/e019_version_0_13_0.html>`_
 ==================================
 
-`2016-01-18 Andreas Rumpf's talk at OSCON Amsterdam <news/2016_01_18_andreas_rumpfs_talk_at_oscon_amsterdam.html>`_
+`2016-01-18 Andreas Rumpf's talk at OSCON Amsterdam <news/e018_oscon_amsterdam.html>`_
 ==================================================
 
-`2015-10-27 Version 0.12.0 released <news/2015_10_27_version_0_12_0_released.html>`_
+`2015-10-27 Version 0.12.0 released <news/e017_version_0_12_0.html>`_
 ==================================
 
-`2015-10-16 First Nim conference <news/2015_10_16_first_nim_conference.html>`_
+`2015-10-16 First Nim conference <news/e016_nim_conf1.html>`_
 ===============================
 
-`2015-05-04 Version 0.11.2 released <news/2015_05_04_version_0_11_2_released.html>`_
+`2015-05-04 Version 0.11.2 released <news/e015_version_0_11_2.html>`_
 ==================================
 
-`2015-04-30 Version 0.11.0 released <news/2015_04_30_version_0_11_0_released.html>`_
+`2015-04-30 Version 0.11.0 released <news/e014_version_0_11_0.html>`_
 ==================================
 
-`2014-12-29 Version 0.10.2 released <news/2014_12_29_version_0_10_2_released.html>`_
+`2014-12-29 Version 0.10.2 released <news/e013_version_0_10_2.html>`_
 ==================================
 
 
-`2014-10-19 Version 0.9.6 released <news/2014_10_19_version_0_9_6_released.html>`_
+`2014-10-19 Version 0.9.6 released <news/e012_version_0_9_6.html>`_
 =================================
 
 
-`2014-04-21 Version 0.9.4 released <news/2014_04_21_version_0_9_4_released.html>`_
+`2014-04-21 Version 0.9.4 released <news/e011_version_0_9_4.html>`_
 =================================
 
 
-`2014-02-11 Nimrod Featured in Dr. Dobb's Journal <news/2014_02_11_nimrod_featured_in_dr_dobbs_journal.html>`_
+`2014-02-11 Nimrod Featured in Dr. Dobb's Journal <news/e010_dr_dobbs_journal.html>`_
 ================================================
 
 
-`2014-01-15 Andreas Rumpf's talk on Nimrod at Strange Loop 2013 is now online <news/2014_01_15_andreas_rumpfs_talk_on_nimrod.html>`_
+`2014-01-15 Andreas Rumpf's talk on Nimrod at Strange Loop 2013 is now online <news/e009_andreas_rumpfs_talk.html>`_
 ============================================================================
 
 
-`2013-05-20 New website design! <news/2013_05_20_new_website_design.html>`_
+`2013-05-20 New website design! <news/e008_new_website.html>`_
 ==============================
 
 
 
-`2013-05-20 Version 0.9.2 released <news/2013_05_20_version_0_9_2_released.html>`_
+`2013-05-20 Version 0.9.2 released <news/e007_version_0_9_2.html>`_
 =================================
 
 
 
-`2012-09-23 Version 0.9.0 released <news/2012_09_23_version_0_9_0_released.html>`_
+`2012-09-23 Version 0.9.0 released <news/e006_version_0_9_0.html>`_
 =================================
 
 
 
-`2012-02-09 Version 0.8.14 released <news/2012_02_09_version_0_8_14_released.html>`_
+`2012-02-09 Version 0.8.14 released <news/e005_version_0_8_14.html>`_
 ==================================
 
 
 
-`2011-07-10 Version 0.8.12 released <news/2011_07_10_version_0_8_12_released.html>`_
+`2011-07-10 Version 0.8.12 released <news/e004_version_0_8_12.html>`_
 ==================================
 
 
-`2010-10-20 Version 0.8.10 released <news/2010_10_20_version_0_8_10_released.html>`_
+`2010-10-20 Version 0.8.10 released <news/e003_version_0_8_10.html>`_
 ==================================
 
 
 
-`2010-03-14 Version 0.8.8 released <news/2010_03_14_version_0_8_8_released.html>`_
+`2010-03-14 Version 0.8.8 released <news/e002_version_0_8_8.html>`_
 =================================
 
 
-`2009-12-21 Version 0.8.6 released <news/2009_12_21_version_0_8_6_released.html>`_
+`2009-12-21 Version 0.8.6 released <news/e001_version_0_8_6.html>`_
 =================================
 
 
diff --git a/web/news/2009_12_21_version_0_8_6_released.rst b/web/news/e001_version_0_8_6.rst
index 019168a44..019168a44 100644
--- a/web/news/2009_12_21_version_0_8_6_released.rst
+++ b/web/news/e001_version_0_8_6.rst
diff --git a/web/news/2010_03_14_version_0_8_8_released.rst b/web/news/e002_version_0_8_8.rst
index 2df476814..2df476814 100644
--- a/web/news/2010_03_14_version_0_8_8_released.rst
+++ b/web/news/e002_version_0_8_8.rst
diff --git a/web/news/2010_10_20_version_0_8_10_released.rst b/web/news/e003_version_0_8_10.rst
index f72c0076c..f72c0076c 100644
--- a/web/news/2010_10_20_version_0_8_10_released.rst
+++ b/web/news/e003_version_0_8_10.rst
diff --git a/web/news/2011_07_10_version_0_8_12_released.rst b/web/news/e004_version_0_8_12.rst
index 5f154b2db..5f154b2db 100644
--- a/web/news/2011_07_10_version_0_8_12_released.rst
+++ b/web/news/e004_version_0_8_12.rst
diff --git a/web/news/2012_02_09_version_0_8_14_released.rst b/web/news/e005_version_0_8_14.rst
index 4050c8b93..4050c8b93 100644
--- a/web/news/2012_02_09_version_0_8_14_released.rst
+++ b/web/news/e005_version_0_8_14.rst
diff --git a/web/news/2012_09_23_version_0_9_0_released.rst b/web/news/e006_version_0_9_0.rst
index 5635ca94c..5635ca94c 100644
--- a/web/news/2012_09_23_version_0_9_0_released.rst
+++ b/web/news/e006_version_0_9_0.rst
diff --git a/web/news/2013_05_20_version_0_9_2_released.rst b/web/news/e007_version_0_9_2.rst
index 89352c06c..89352c06c 100644
--- a/web/news/2013_05_20_version_0_9_2_released.rst
+++ b/web/news/e007_version_0_9_2.rst
diff --git a/web/news/2013_05_20_new_website_design.rst b/web/news/e008_new_website.rst
index b36cc99dd..b36cc99dd 100644
--- a/web/news/2013_05_20_new_website_design.rst
+++ b/web/news/e008_new_website.rst
diff --git a/web/news/2014_01_15_andreas_rumpfs_talk_on_nimrod.rst b/web/news/e009_andreas_rumpfs_talk.rst
index 00cc5e101..00cc5e101 100644
--- a/web/news/2014_01_15_andreas_rumpfs_talk_on_nimrod.rst
+++ b/web/news/e009_andreas_rumpfs_talk.rst
diff --git a/web/news/2014_02_11_nimrod_featured_in_dr_dobbs_journal.rst b/web/news/e010_dr_dobbs_journal.rst
index b48ccf31f..b48ccf31f 100644
--- a/web/news/2014_02_11_nimrod_featured_in_dr_dobbs_journal.rst
+++ b/web/news/e010_dr_dobbs_journal.rst
diff --git a/web/news/2014_04_21_version_0_9_4_released.rst b/web/news/e011_version_0_9_4.rst
index 2714c5c78..2714c5c78 100644
--- a/web/news/2014_04_21_version_0_9_4_released.rst
+++ b/web/news/e011_version_0_9_4.rst
diff --git a/web/news/2014_10_19_version_0_9_6_released.rst b/web/news/e012_version_0_9_6.rst
index 7a148aaa5..7a148aaa5 100644
--- a/web/news/2014_10_19_version_0_9_6_released.rst
+++ b/web/news/e012_version_0_9_6.rst
diff --git a/web/news/2014_12_29_version_0_10_2_released.rst b/web/news/e013_version_0_10_2.rst
index ad8afa3bf..ad8afa3bf 100644
--- a/web/news/2014_12_29_version_0_10_2_released.rst
+++ b/web/news/e013_version_0_10_2.rst
diff --git a/web/news/2015_04_30_version_0_11_0_released.rst b/web/news/e014_version_0_11_0.rst
index a8a58f2ae..a8a58f2ae 100644
--- a/web/news/2015_04_30_version_0_11_0_released.rst
+++ b/web/news/e014_version_0_11_0.rst
diff --git a/web/news/2015_05_04_version_0_11_2_released.rst b/web/news/e015_version_0_11_2.rst
index 273182340..273182340 100644
--- a/web/news/2015_05_04_version_0_11_2_released.rst
+++ b/web/news/e015_version_0_11_2.rst
diff --git a/web/news/2015_10_16_first_nim_conference.rst b/web/news/e016_nim_conf1.rst
index 228bffd28..228bffd28 100644
--- a/web/news/2015_10_16_first_nim_conference.rst
+++ b/web/news/e016_nim_conf1.rst
diff --git a/web/news/2015_10_27_version_0_12_0_released.rst b/web/news/e017_version_0_12_0.rst
index 63088f9e2..63088f9e2 100644
--- a/web/news/2015_10_27_version_0_12_0_released.rst
+++ b/web/news/e017_version_0_12_0.rst
diff --git a/web/news/2016_01_18_andreas_rumpfs_talk_at_oscon_amsterdam.rst b/web/news/e018_oscon_amsterdam.rst
index fcb4a8794..fcb4a8794 100644
--- a/web/news/2016_01_18_andreas_rumpfs_talk_at_oscon_amsterdam.rst
+++ b/web/news/e018_oscon_amsterdam.rst
diff --git a/web/news/2016_01_18_version_0_13_0_released.rst b/web/news/e019_version_0_13_0.rst
index 2c8e66fa3..2c8e66fa3 100644
--- a/web/news/2016_01_18_version_0_13_0_released.rst
+++ b/web/news/e019_version_0_13_0.rst
diff --git a/web/news/2016_01_27_nim_in_action_is_now_available.rst b/web/news/e020_nim_in_action.rst
index 33bcb7947..33bcb7947 100644
--- a/web/news/2016_01_27_nim_in_action_is_now_available.rst
+++ b/web/news/e020_nim_in_action.rst
diff --git a/web/news/2016_06_04_meet_our_bountysource_sponsors.rst b/web/news/e021_meet_sponsors.rst
index 0bfb472c5..0bfb472c5 100644
--- a/web/news/2016_06_04_meet_our_bountysource_sponsors.rst
+++ b/web/news/e021_meet_sponsors.rst
diff --git a/web/news/2016_06_07_version_0_14_0_released.rst b/web/news/e022_version_0_14_0.rst
index 6634d0053..6634d0053 100644
--- a/web/news/2016_06_07_version_0_14_0_released.rst
+++ b/web/news/e022_version_0_14_0.rst
diff --git a/web/news/2016_06_11_version_0_14_2_released.rst b/web/news/e023_version_0_14_2.rst
index cbfe52713..cbfe52713 100644
--- a/web/news/2016_06_11_version_0_14_2_released.rst
+++ b/web/news/e023_version_0_14_2.rst
diff --git a/web/news/2016_06_23_launching_the_2016_nim_community_survey.rst b/web/news/e024_survey.rst
index 0b87577aa..0b87577aa 100644
--- a/web/news/2016_06_23_launching_the_2016_nim_community_survey.rst
+++ b/web/news/e024_survey.rst
diff --git a/web/news/2016_08_06_bountysource_update_the_road_to_v10.rst b/web/news/e025_bountysource_update.rst
index 00ca7022e..00ca7022e 100644
--- a/web/news/2016_08_06_bountysource_update_the_road_to_v10.rst
+++ b/web/news/e025_bountysource_update.rst
diff --git a/web/news/2016_09_03_nim_community_survey_results.rst b/web/news/e026_survey_results.rst
index 106dce0e4..106dce0e4 100644
--- a/web/news/2016_09_03_nim_community_survey_results.rst
+++ b/web/news/e026_survey_results.rst
diff --git a/web/news/2016_09_30_version_0_15_0_released.rst b/web/news/e027_version_0_15_0.rst
index 47c02e9e4..47c02e9e4 100644
--- a/web/news/2016_09_30_version_0_15_0_released.rst
+++ b/web/news/e027_version_0_15_0.rst
diff --git a/web/news/e028_version_0_15_2.rst b/web/news/e028_version_0_15_2.rst
new file mode 100644
index 000000000..601a26646
--- /dev/null
+++ b/web/news/e028_version_0_15_2.rst
@@ -0,0 +1,77 @@
+Version 0.15.2 released
+=======================
+
+.. container:: metadata
+
+  Posted by Andreas Rumpf on 23/10/2016
+
+We're happy to announce that the latest release of Nim, version 0.15.2, is now
+available!
+
+As always, you can grab the latest version from the
+`downloads page <http://nim-lang.org/download.html>`_.
+
+This release is a pure bugfix release fixing the most pressing issues and
+regressions of 0.15.0. For Windows we now provide zipfiles in addition to the
+NSIS based installer which proves to be hard to maintain and after all these
+months still has serious issues. So we encourage you download the .zip
+file instead of the .exe file! Unzip it somewhere, run ``finish.exe`` to
+detect your MingW installation, done. ``finish.exe`` can also set your PATH
+environment variable.
+
+
+Bugfixes
+--------
+
+The list below has been generated based on the commits in Nim's git
+repository. As such it lists only the issues which have been closed
+via a commit, for a full list see
+`this link on Github <https://github.com/nim-lang/Nim/issues?utf8=%E2%9C%93&q=is%3Aissue+closed%3A%222016-09-30+..+2016-10-23%22+>`_.
+
+
+- Fixed "`NimMain` not exported in DLL, but `NimMainInner` is"
+  (`#4840 <https://github.com/nim-lang/Nim/issues/4840>`_)
+- Fixed "Tables clear seems to be broken"
+  (`#4844 <https://github.com/nim-lang/Nim/issues/4844>`_)
+- Fixed "compiler: internal error"
+  (`#4845 <https://github.com/nim-lang/Nim/issues/4845>`_)
+- Fixed "trivial macro breaks type checking in the compiler"
+  (`#4608 <https://github.com/nim-lang/Nim/issues/4608>`_)
+- Fixed "derived generic types with static[T] breaks type checking in v0.15.0 (worked in v0.14.2)"
+  (`#4863 <https://github.com/nim-lang/Nim/issues/4863>`_)
+- Fixed "xmlparser.parseXml is not recognised as GC-safe"
+  (`#4899 <https://github.com/nim-lang/Nim/issues/4899>`_)
+- Fixed "async makes generics instantiate only once"
+  (`#4856 <https://github.com/nim-lang/Nim/issues/4856>`_)
+- Fixed "db_common docs aren't generated"
+  (`#4895 <https://github.com/nim-lang/Nim/issues/4895>`_)
+- Fixed "rdstdin  disappeared from documentation index"
+  (`#3755 <https://github.com/nim-lang/Nim/issues/3755>`_)
+- Fixed "ICE on template call resolution"
+  (`#4875 <https://github.com/nim-lang/Nim/issues/4875>`_)
+- Fixed "Invisible code-block"
+  (`#3078 <https://github.com/nim-lang/Nim/issues/3078>`_)
+- Fixed "nim doc does not generate doc comments correctly"
+  (`#4913 <https://github.com/nim-lang/Nim/issues/4913>`_)
+- Fixed "nim doc2 fails on ARM when running against lib/pure/coro.nim"
+  (`#4879 <https://github.com/nim-lang/Nim/issues/4879>`_)
+- Fixed "xmlparser does not unescape correctly"
+  (`#1518 <https://github.com/nim-lang/Nim/issues/1518>`_)
+- Fixed "[docs] mysterious "raise hook""
+  (`#3485 <https://github.com/nim-lang/Nim/issues/3485>`_)
+- Fixed "assertion failure in non-release Nim when compiling NimYAML"
+  (`#4869 <https://github.com/nim-lang/Nim/issues/4869>`_)
+- Fixed "A closure causes nimscript to fail with unhandled exception"
+  (`#4906 <https://github.com/nim-lang/Nim/issues/4906>`_)
+- Fixed "startProcess changes working directory"
+  (`#4867 <https://github.com/nim-lang/Nim/issues/4867>`_)
+- Fixed "bindsym to void template produces ICE"
+  (`#4808 <https://github.com/nim-lang/Nim/issues/4808>`_)
+- Fixed "readline(TFile, var string) segfaults if second argument is nil"
+  (`#564 <https://github.com/nim-lang/Nim/issues/564>`_)
+- Fixed "times.parse gives the wrong day of the week for the first hour of the day."
+  (`#4922 <https://github.com/nim-lang/Nim/issues/4922>`_)
+- Fixed "Internal error when passing parameter proc inside .gcsafe closure"
+  (`#4927 <https://github.com/nim-lang/Nim/issues/4927>`_)
+- Fixed "Upcoming asyncdispatch doesn't compile with C++ backend on OS X"
+  (`#4928 <https://github.com/nim-lang/Nim/issues/4928>`_)
diff --git a/web/news/e029_version_0_16_0.rst b/web/news/e029_version_0_16_0.rst
new file mode 100644
index 000000000..1d3f3b3df
--- /dev/null
+++ b/web/news/e029_version_0_16_0.rst
@@ -0,0 +1,53 @@
+Version 0.16.0 released
+=======================
+
+.. container:: metadata
+
+  Posted by xyz on dd/mm/yyyy
+
+We're happy to announce that the latest release of Nim, version 0.16.0, is now
+available!
+
+As always, you can grab the latest version from the
+`downloads page <http://nim-lang.org/download.html>`_.
+
+This release includes almost xyz bug fixes and improvements. To see a full list
+of changes, take a look at the detailed changelog
+`below <#changelog>`_.
+
+Some of the most significant changes in this release include: xyz
+
+
+Changelog
+~~~~~~~~~
+
+Changes affecting backwards compatibility
+-----------------------------------------
+
+- ``staticExec`` now uses the directory of the nim file that contains the
+  ``staticExec`` call as the current working directory.
+
+
+Library Additions
+-----------------
+
+
+Tool Additions
+--------------
+
+
+Compiler Additions
+------------------
+
+
+Language Additions
+------------------
+
+
+Bugfixes
+--------
+
+The list below has been generated based on the commits in Nim's git
+repository. As such it lists only the issues which have been closed
+via a commit, for a full list see
+`this link on Github <https://github.com/nim-lang/Nim/issues?utf8=%E2%9C%93&q=is%3Aissue+closed%3A%222016-06-22+..+2016-09-30%22+>`_.
diff --git a/web/sponsors.csv b/web/sponsors.csv
index fe0261d17..0701575d5 100644
--- a/web/sponsors.csv
+++ b/web/sponsors.csv
@@ -1,36 +1,34 @@
 logo, name, url, this_month, all_time, since, level
-,bogen,https://github.com/bogen,250,1010,"Jul 23, 2016",250
-assets/bountysource/secondspectrum.png,Second Spectrum,http://www.secondspectrum.com/,250,1000,"May 5, 2016",250
-assets/bountysource/xored.svg,"Xored Software, Inc.",http://xored.com/,250,750,"Jun 20, 2016",250
-,flyx,http://flyx.org,35,175,"Apr 7, 2016",75
-,shkolnick-kun,https://github.com/shkolnick-kun,75,150,"Jul 6, 2016",75
-,"Yuriy Glukhov",,25,125,"Apr 6, 2016",25
-,endragor,https://github.com/endragor,25,125,"Apr 7, 2016",25
-,FedericoCeratto,http://firelet.net,25,125,"Apr 7, 2016",25
-,"Adrian Veith",,25,125,"Apr 20, 2016",25
-,avsej,http://avsej.net,25,110,"Jun 10, 2016",25
-,euantorano,http://euantorano.co.uk,25,75,"Jun 7, 2016",25
-,xxlabaza,https://github.com/xxlabaza,25,70,"Jun 17, 2016",25
-,btbytes,https://www.btbytes.com/,10,50,"Apr 6, 2016",10
-,niebaopeng,https://github.com/niebaopeng,10,40,"Apr 15, 2016",10
+assets/bountysource/secondspectrum.png,Second Spectrum,http://www.secondspectrum.com/,250,1250,"May 5, 2016",250
+assets/bountysource/xored.svg,"Xored Software, Inc.",http://xored.com/,250,1000,"Jun 20, 2016",250
+,shkolnick-kun,https://github.com/shkolnick-kun,75,225,"Jul 6, 2016",75
+,flyx,http://flyx.org,35,210,"Apr 7, 2016",75
+,"Yuriy Glukhov",,25,150,"Apr 6, 2016",25
+,endragor,https://github.com/endragor,25,150,"Apr 7, 2016",25
+,FedericoCeratto,http://firelet.net,25,150,"Apr 7, 2016",25
+,"Adrian Veith",,25,150,"Apr 20, 2016",25
+,skunkiferous,https://github.com/skunkiferous,100,100,"Oct 2, 2016",150
+,euantorano,http://euantorano.co.uk,25,100,"Jun 7, 2016",25
+,xxlabaza,https://github.com/xxlabaza,25,95,"Jun 17, 2016",25
+,btbytes,https://www.btbytes.com/,10,60,"Apr 6, 2016",10
+,niebaopeng,https://github.com/niebaopeng,10,50,"Apr 15, 2016",10
+,"Jonathan Arnett",,10,50,"May 20, 2016",10
+,swalf,https://github.com/swalf,5,45,"May 9, 2016",5
+,zolern,https://github.com/zolern,10,40,"Apr 15, 2016",10
 ,"pyloor ",https://schwarz-weiss.cc/,10,40,"May 16, 2016",10
-,"Jonathan Arnett",,10,40,"May 20, 2016",10
-,swalf,https://github.com/swalf,5,40,"May 9, 2016",5
-,zachaysan,http://venn.lc,10,30,"Jun 7, 2016",10
-,"Matthew Baulch",,10,30,"Jun 7, 2016",10
-,"Oskari Timperi",,10,30,"Jun 8, 2016",10
-,RationalG,https://github.com/RationalG,10,30,"Jun 17, 2016",10
-,"Handojo Goenadi",,5,25,"Apr 19, 2016",5
-,"Matthew Newton",,5,25,"Apr 20, 2016",5
-,johnnovak,http://www.johnnovak.net/,5,25,"Apr 29, 2016",5
-,moigagoo,http://sloth-ci.com,5,20,"May 13, 2016",5
-,RyanMarcus,http://rmarcus.info,5,10,"Jul 19, 2016",5
-,Blumenversand,https://github.com/blumenversand,5,10,"Jul 21, 2016",5
-,lenzenmi,https://github.com/lenzenmi,5,10,"Jul 28, 2016",5
-,DateinAsia,,5,10,"Jul 30, 2016",5
-,pandada8,https://github.com/pandada8,5,5,"Aug 12, 2016",5
-,abeaumont,http://alfredobeaumont.org/blog,5,5,"Aug 12, 2016",5
-,"Svend Knudsen",,1,5,"Apr 11, 2016",1
-,"Michael D. Sklaroff",,1,5,"Apr 27, 2016",1
-,nicck,,1,1,"Aug 9, 2016",1
-
+,zachaysan,http://venn.lc,10,40,"Jun 7, 2016",10
+,"Matthew Baulch",,10,40,"Jun 7, 2016",10
+,"Oskari Timperi",,10,40,"Jun 8, 2016",10
+,"Handojo Goenadi",,5,35,"Apr 19, 2016",5
+,"Matthew Newton",,5,30,"Apr 20, 2016",5
+,johnnovak,http://www.johnnovak.net/,5,30,"Apr 29, 2016",5
+,RyanMarcus,http://rmarcus.info,5,15,"Jul 19, 2016",5
+,lenzenmi,https://github.com/lenzenmi,5,15,"Jul 28, 2016",5
+,cpunion,https://github.com/cpunion,10,10,"Sep 9, 2016",10
+,pandada8,https://github.com/pandada8,5,10,"Aug 12, 2016",5
+,abeaumont,http://alfredobeaumont.org/blog,5,10,"Aug 12, 2016",5
+,"Svend Knudsen",,1,6,"Apr 11, 2016",1
+,"Michael D. Sklaroff",,1,6,"Apr 27, 2016",1
+,csoriano89,https://github.com/csoriano89,5,5,"Sep 7, 2016",5
+,nicck,,1,2,"Aug 9, 2016",1
+,campbellr,,1,1,"Sep 4, 2016",1
diff --git a/web/ticker.html b/web/ticker.html
index a05ea8476..b59c0a3e9 100644
--- a/web/ticker.html
+++ b/web/ticker.html
@@ -1,24 +1,24 @@
-<a class="news" href="$1news/2016_09_30_version_0_15_0_released.html">
-  <h4>September 30, 2016</h4>
-  <p>Nim version 0.15.0 has been released!</p>
+<a class="news" href="$1news/e028_version_0_15_2.html">
+  <h4>October 23, 2016</h4>
+  <p>Nim version 0.15.2 has been released!</p>
 </a>
 
-<a class="news" href="$1news/2016_09_03_nim_community_survey_results.html">
+<a class="news" href="$1news/e026_survey_results.html">
   <h4>September 3, 2016</h4>
   <p>Nim Community Survey results</p>
 </a>
 
-<a class="news" href="$1news/2016_08_06_bountysource_update_the_road_to_v10.html">
+<a class="news" href="$1news/e025_bountysource_update.html">
   <h4>August 6, 2016</h4>
   <p>BountySource Update: The Road to v1.0</p>
 </a>
 
-<a class="news" href="$1news/2016_06_23_launching_the_2016_nim_community_survey.html">
+<a class="news" href="$1news/e024_survey.html">
   <h4>June 23, 2016</h4>
   <p>Launching the 2016 Nim community survey!</p>
 </a>
 
-<a class="news" href="$1news/2016_06_11_version_0_14_2_released.html">
+<a class="news" href="$1news/e023_version_0_14_2.html">
   <h4>June 11, 2016</h4>
   <p>Nim version 0.14.2 has been released!</p>
 </a>
diff --git a/web/website.ini b/web/website.ini
index 860ab9338..0d1be4b63 100644
--- a/web/website.ini
+++ b/web/website.ini
@@ -31,7 +31,7 @@ file: ticker.html
 [Documentation]
 doc: "endb;intern;apis;lib;manual.rst;tut1.rst;tut2.rst;nimc;overview;filters"
 doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.rst"
-doc: "nimfix.rst;nimsuggest.rst;nep1.rst;nims.rst"
+doc: "nimfix.rst;nimsuggest.rst;nep1.rst;nims.rst;contributing.rst"
 pdf: "manual.rst;lib.rst;tut1.rst;tut2.rst;nimc.rst;niminst.rst;gc.rst"
 srcdoc2: "system.nim;system/nimscript;pure/ospaths"
 srcdoc2: "core/macros;pure/marshal;core/typeinfo"
@@ -45,7 +45,7 @@ srcdoc2: "pure/parseopt;pure/parseopt2;pure/hashes;pure/strtabs;pure/lexbase"
 srcdoc2: "pure/parsecfg;pure/parsexml;pure/parsecsv;pure/parsesql"
 srcdoc2: "pure/streams;pure/terminal;pure/cgi;pure/unicode;pure/strmisc"
 srcdoc2: "pure/htmlgen;pure/parseutils;pure/browsers"
-srcdoc2: "impure/db_postgres;impure/db_mysql;impure/db_sqlite"
+srcdoc2: "impure/db_postgres;impure/db_mysql;impure/db_sqlite;pure/db_common"
 srcdoc2: "pure/httpserver;pure/httpclient;pure/smtp;impure/ssl;pure/fsmonitor"
 srcdoc2: "pure/ropes;pure/unidecode/unidecode;pure/xmldom;pure/xmldomparser"
 srcdoc2: "pure/xmlparser;pure/htmlparser;pure/xmltree;pure/colors;pure/mimetypes"
@@ -63,7 +63,7 @@ srcdoc2: "deprecated/pure/ftpclient"
 srcdoc2: "pure/asyncfile;pure/asyncftpclient"
 srcdoc2: "pure/md5;pure/rationals"
 srcdoc2: "posix/posix"
-srcdoc2: "pure/fenv;pure/securehash"
+srcdoc2: "pure/fenv;pure/securehash;impure/rdstdin"
 srcdoc2: "pure/basic2d;pure/basic3d;pure/mersenne;pure/coro;pure/httpcore"
 
 ; Note: everything under 'webdoc' doesn't get listed in the index, so wrappers