Refactoring new API. Not finished yet