rework the update algorithm to be robuster and a little bit faster, also
the $orphans parameter was removed, because its no longer needed