Added comments, slight refactor