Initial implementation and some tests.