Refactor code slightly

Aiming for < 100 LOC per file, to keep components small and easy to understand.
Fix a bug in how we draw frequency

If the last value drawn for the frequency is not zero, then the entire
frequency chart is drawn off at a crazy angle until it subsides again.