Add allowed values and nested variables

Along with a bit of refactoring