stsm: safe casting (close one, open other retriever)
stsm: various fixes and refactorings

- always send the set-id if available