Spontaneity and free energy