Refactor render(...) function (again).