Fix chapter behavior at edges