Use rtl::Reference to make code clearer & exception-safe

Change-Id: I8cfdf792541b351a19e16f95d4e6f7127e3d33b2