Various bugfixes from coverage testing

Shaking some of the bugs out of my next branch for a stable release.