Massive refactor in progress.