code cleanup; added comments.