Better error handling. Added options to command line.