First implementation and tests.