Only import grp and pwd if we need them for Unix codepath.
Restructured logic to work on windows machines.
Fixed whitespace errors introduced while editing on Windows machine.
Merge branch 'windows-grp'

Tested on windows and linux, looks like it's working properly.