Tidied up a bit - still work to do... but all tests passing