Oscillator functions and some cleanup