Finished first stage refactoring of API