Refactor API to avoid cycle