Merge pull request #17 from bochecha/master

Cleanup, and big refactoring of the frequency code