Pass $ag as a constructor parameter, don't just get the global.