Refactor API, reorganize