Implemented saving and loading of gates