Initial code

Initial code and tests.