Bugfix on ancestor ordering