SED from Cube code

Made a pull request while I work on this in case you have comments.
Give the usual message to the `ValueError` (search the code for other examples if it's not clear what I mean).