API mode refactor