Beginning of refacto.