more comments and code cleanup