Refactor Main.java so it's easier to subclass and customize.