Adds comments, moves around some code