Changed from odeint to ode for better performance.