Refactor runMainWithExitCode method

Method was over 100 lines and initialized the variables on every
command, including version queries. Factor out to smaller methods
and lazy load variables as needed.
Add automated verification builds

To avoid problems with broken commits enable travis-ci. Note that
the default build command is `ant test`, which fails builds if
tests fail.