More robust handling, catering for some edge cases, and supporting forward and backward sigs

Still todo:
 - support for more edge cases, in particular where the first or last char can be represented with just a few bits, because the last byte *can* be truncated!
 - better handling when there are repeats of the index 0 on both sides (e.g. "aaroaa"). This is unlikely to present itself with real words, but handling could be added for completeness...