code cleanup; untested