some reordering of retcode handling