Changing API slightly, adding documentation and tests