misc clean-ups
implement unique algorithm