moved utility functions for nesting and sorting sequence blocks from the exporter into the model class, so that it can be reused in the controller as well.