code cleanup; also noted potential memory issue in comment