found a strange bug and fixed it in __into_modes. Now the algorithm returns the correct result and is very fast