Slightly improved performance; code cleanup