Declared some variables volatile that always should have been.