API refactoring and serialization