Sorted type templates and complex type support fix