Got the basic page generation working.
Still need to fix the algorithm, and do the database stuff