general code cleaning and commenting