bug fixes and tweaks to pr feedback
bug fix