Rewrite.

Near complete rewrite. More maintainable. Loop navigation. Padding fix.
Racing lock.