Refactor for better API.