Large refactor to a more modular setup.