Render refactor (with couple of fixes)

i need some static vars which i can reuse everywhere, but i don't mind to rename them