Full rewrite.

At least now its not so painful to read, nor so inefficient.
Natives actually extract now, too.