Cleaning and commenting some functions.