code cleanup, adding comments