What formed on the outside of the earth after it cooled?