added two new columns to template, managed missing data, and fixed a bug in knn for small input data sets