Fixes tangle algorithm