added more comments, code cleanup