made renderstate parsing generic, removed dupe code