added comments, performed cleanup