Some code cleaning and comments added.