Update find_by_ptr and add find_by_ref_count