added functionality to detect orphans. Have yet to deal with them.