replace custom ref counted thing with a shared_ptr Change-Id: I9d61235e38cc4c708826cf76d9edc2880b4b5ec7