Fixed some issues in the temp paging algorithm