state_diagrams: better prefix stripping