Minor bug fixes and tweaks