Fixed bug with handling unsorted model variables.
Merge branch 'devel' of 'internal' into devel