flann, memory fixes