Code cleanup.
Fixed a bug where gates did not work after chaining it's location.