New more stable code for long simulations