Replace Agent::GetInstance() with agent object passed down