Fix addReference bug