Moving functions to appropriate places.