scoping and whitespace cleanup