WIP: More cluster stats options

This adds support for the "haircut" technique and for threshold-free cluster enhancement. Still needs tests and validation. Also cleans up / speeds up some clustering code.