Proper filtering of pages obtained from get_pages()
Various small fixes.