Some code cleanup. Initial migration of Windows port efforts.