Cleaned up command line parsing a bit. Removed state from parsing code.
Merge branch 'commandlinecleanup' into mergecommandline