Fixing the issues related to tree refresh and selection mismatch