Code cleaning and documentation