Added comments, cleaned formatting a little