improved xoffsetfactor re-alignment code