Bug fixes

Did some tuning and fixed some memory corruption issues which appeared
to be the result of mixing DLL and non-DLL based MSVC runtime libraries.
HAH.