Added a bunch of comments and refracted a bunch