First iteration code and tests.