Display a more helpful message if all frequencies set to zero
Reduce algorithm time to O(N^2) (fixes #9)