Fixed problem where flann indexes were not properly deleted. And other things