Lots of various fixes