A slew of bug fixes and tweaks