general refactorings, correcting a bug in the toDescendant package method