Making everything work on Windows again, more platform-agnostic rewrites, some cleanup.