Added comments, cleaned up a bit