Removed megaMain(); split it up into smaller, more well-defined
methods.