Feature #4977: Refactor some API