Fixed release/debug DLLs in Windows

Also fixed a number of other release build problems