Updated Main class and refactored code on whole project.