Fix for errors in non-commandline-arg mode.

There was a problem that would have stopped the program from working if
the arguments were not passed via command line.

Some further optimizations were done.
Merge branch 'patch-2.1'