Moved frequency calculation to another method.
Removed lots of unused code.