Whoops, delete some debugging prints.
Implement tfold.
Fix a bug to allow `fold` to occur at the top level.

This means that it is possible to occasionally generate a fold that
would be classed as a tfold, but this just means we do some extra work
(can be solved later if necessary); we should still be able to find
everything.