Lots of minor tweaks and fixes