Use Unicode API on Win32

This fixes #115.
Also includes some minor changes.