Bug fixes and minor tweaks.