FS-2731 refactor a bit to make this actually usable and more cross-endpoint compatible