fixed some bugs which prevented the Win32 version from working.