Lots of random small fixes and cleanups