Fix bug with allocating pages