Gen.frequency
- fix off-by-one error
- handle empty sequences