allow reuse of gates and fix destruction code