Main class and bug fixes after testing