Render refactor (with couple of fixes)

We put static functions on top in a lot of places.