Cleanup and win32 fixes for linenoise

Needs testing. Please don't merge before having verified that it actually works.