Refactor Thread UI markup as a template