Update spec to refactor. Fix some errors identified by spec.