Refactor api package