Some bug fixes and tweaks.