Added sorting and updated templates