When applying the meringue to the top of the pie, make sure you spread it over onto the edge of the pie crust. If the meringue is touching the crust all around, it will stick and prevent gaps during baking.
Be careful not to over-bake the meringue. That's what causes those little golden beads of liquid on the meringue.
Also, have the meringue ready to go when you add the hot filling to the crust. Then sprinkle some cake crumbs on the top of the filling before adding the meringue. These crumbs will absorb any liquid that collects between the bottom of the meringue and the top of the filling.
"If you want to make an apple pie from scratch, you must first create the universe." -Carl Sagan