some code cleaning and comments