Fix sorting in notepad, fix minor template errors