Reduce memory usage of MQDF. Remove unused codes of KNN.
Let smart ptr thread-safe.
Fix some bugs in smart ptr. Reduce memory usage in MQDF.