Add in output status parameter, plus kdtree