try, and fail, to find a way to balance between ref and mem management