bug fixes and tweaks