CRA-606: bugfix for 4D inversion

Many small fixes to make 4D run smoother