A little bit of cleaning of outdated comments and changed order and name of some functions to add clarity and consistency.