Refactor API structure