Reorganize update code.