Lots of bug fixes

Lots of behavioral bug fixes.