Cleanup, streamlining and tests

Some commits appear to have duplicates. I don't understand how. Probably because of rebase, which it looks like I ought to avoid