A bunch of changes for compatibility with windows
Merged os x and windows changes