Added command line handling.
Command line parsing, without errors.

Or rather with errors, but no structure.
Cleaned up and added better control flow and error handling.