added comments and removed debug code.