Refactored into lib.