RenderState reworked

some optimizations still pending