Cleaning the code and removing some unused code