Fixing reference issues