Some changes to support pongo2 render middleware