Lots of various fixes.