Windows port, and some cleanups.