Added windows compatibility and cleaned up the code a bit
Proper encoding of windows defaults
Moved the open directory code into a function