changed the type of num_refs to size_t