WIP. Code refactor.