Various Fixes

It seems #168 stole my ideas so well that the test suite passes on my changes in #166 as re-added here.