Improvement of the following revision: bbc629eb This might still be problematic if freq = 0, so it's better to check for that.