Updating KNN to use Immutable types for thread safety