Code cleaning and commenting