Lots more tweaks and fixes