Bunch of misc fixes.