fix ternary operator, tweak scoping rules, and start implementing default