Added core functionality to frequency.py.