Towards a realistic theory of the geodynamo