pkg: implement refcounting and a deeper cache