Reformatted and added a few comments