Added more comments, removed debug printfs