Windows compatibility and general cleanup