Added check_parentage and flag functions.