bug fixes and minor tweaks