add gates to structures, all but template parsing