fix gate dupe bug, rewrite quarry logic