Changed method name to resolve_gates and fixed bugs
Changed method name to resolve_gates