Fixing reference errors