Whitespace cleanup and move vars closer to usage