Generate_Pages: slightly refactored.