Fix lastpage bug in state machine in page parser