clustering bug fix and memory reduce