Code cleaning and formatting