Fix some problems introduced in Windows port