Refactored threads pagination to fit with the TemplateModule system.