tweak refcounting of shared libraries to match example