Lots of misc small fixes