Fix 514 tx bug: Fix tree-hash cnt n^2. Asserts, comment. Squash2

That should work, but please finish testing before merge.