Added some comments/changed function names