Added comments, updated some code