Refactor out an API class and UI singletons