Renaming, added comments, minor code improvements

Renamed functions, parameters and variables; added some comments; some
small code improvements