Set main class and fix bugs to make code compilable