Clean up some variable scoping, less public variable access