Refactored with API glue functions.