Fix stupid logic in integrator and other little changes