Big api refactoring