Refactor into modules to improve reuse.