Added comments and a bug fix