Some minor bug fixes and tweaks.