Add more tests and remove unused code.