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!