Fixed a bug with redefinition and references