added start of window module

also fixed err module so that err_die cleanup is done
per-thread instead of per-module.