Comments, clean up

Commented the code/functions, cleaned up some of the mess.