Finish implementation. Untested.
Start adding tests.
Found a bug.