Variable scope fix for $core