Refactor renderContents() deduplication code

Change-Id: Ib8672b51fc236cac805b88a99d07b3c496548cbd