Fixed lots of bugs 2 clustering alg, still needs some adjustments