How do I prevent the foil from sliding around in the pan?

To ensure better adhesion of the foil to the pan you can sprinkle some drops of water or oil in the pan before lining it with the foil.  This improves the contact between the foil and the pan, sealing the foil to the pan for better heat conduction.