fix refcounting issues with table