Added command-line argument parsing. Cleaned things up a bit.