Fix bugs. Add acceptance tests.