Some local refactorings to make code simpler.