Fix Redmond's ERRORs
Don't redefine min() if it's already there
Add a missing include for Windows
Make boolean definitions OS dependend