Changed code regarding the handling of moving forward and backward
through pages.