Significant API improvments, bugfixes, documentation, and extra tests.