code cleanup; 1.5x speed up