Improve pagetable logic