Added remove orphans function.