Moved configuration loading entirely to main program. Also added command line options.