optimizations and renderstate fixes