Lots of general improvements