Backporting the changes in the v6.7.0 branch into the 6.6.1 branch - fixed a bunch of bugs, and added 60+ new tests that shoulda been there, beforehand. Lots of improvements - hopefully less code than before!
Merge branch 'bugfixes-6_6_1'
s/6.6.0/6.6.1/g;