Media API refactor