Tidying up

Just some miscellaneous fixes while doing some more thorough testing.