Fixed style a little and added a bunch of comments here and there