Base code for main class.