Fixing bad references