Clean up some Gate code