Almost done, but rewriting it will be boring.