fix a leak with callback exceptions
accelerate cluster with sorting.

(better memory access pattern)
add comments in cluster.py