Move part of the syncthing controller into a common file