Fixed many api and tests.