Fix scoping and whitespace