Fix bug in full template selection (bad index).