[master] Fat commit: change templates + Add custom sorting functions