Cleaning the code and adding classes