a few fixes and tweaks arising from code review