An elephant of a refactor. Plus introducing some specs.