Fixing circular dependency and table variable access