A first version which passed some simple tests.