Cleanup, streamlining and tests

Some commits appear to have duplicates. I don't understand how