Reimplementing scantwo perms by H-K, to get around with memory problems