Cleaned up script for use in windows and *nix