Fixed Windows-only code, and added main file for testing.