bug fix. self-thinning algorithm.