Refactor to remove superfluous usage of x_id and x.id