Added comments and updates to code