Bunch of fixes and minor tweaks.