fixes and a bit of cleanup