Added argument parsing, cleaned up code.