comments and some code cleanup