Render refactor (with couple of fixes)

What's the point of this function?