Add sorting capabilities, fix issue with renaming templates