Fixed out-of-bounds problem where templates would sometimes have less than N points.