Use frequency arrays to solve clumps problem. Fixes #1