Code cleaning and adding comments