fixes bug in gate spawning mechanism