continue work on new-style variables/constraints
some refactoring/reordering