Changed API and updated/refined the documentation. Added tests for API changes.