implement ERROR_REASON, fix problem with regen states