Fix gate.cpp