Add implementation and some tests.