adding comments and some minor cleanup