sort out exit codes and return codes