Added Windows support

Please review and see if it breaks stuff in OSX/Linux. Meanwhile, I will look into remaining WIndows hacks and figure out how to avoid them.