Reorganized the code of the provider.