Big fat refactor. Feels good.