added basic input error-checking, cleaned up code
changed commandline structure to simpler version with flags