Added some configuration options and clean up main program