Reimplemented the whole thing!