Add more unit tests. Organize API into separate files.