Add allowed values and nested variables

along with a bit of a refactoring to reveal intention.