Added comments and a little cleanup