Changed precision to double in most places and fixed oscillator position going out of bounds.