Most non-frequency changes made, changed variable names to be more consistent, fixed a few bugs.