Fix reference counter