Added cmd arg parser, cleaned things up a bit