Bifurcations and stability of gap solitons in periodic potentials.