more comments, some code cleanup