Refactoring api. (first iteration)