Added handling of wrapping cycles. Fixed parentage checking. Added more examples.