Update comments, reorganize some code, rename variables to be