Improve cardsort template and fix end template bug