More refactoring of page creation, still not thread safe