Add allowed values and nested variables

Along with a general refactoring