Refactor to more modular style.