Major api refactorings.