Move things around a little and add comments for documentation purposes.