Better templating for pages (including pagination link) + code cleaning