[DF-5527] Improvements for ScopedPtr and RefPtr