Better alg inversion in twisty.js