changed get_available_pages() to do (a lot) less reads.