code cleaning and documentation