Cleaning and commenting of the code