A patch to loop detection in smart_encode from Dag-Erling Smørgrav.
Some other minor bits.
RT#83108: Fixed a spelling error. Some other fixes, too.