Added correct handling of 0 frequency.