WIP: Commit so don't lose work. Unfinished refactor for optimization.