removing some serious inefficiencies, fixing a change that broke compatibility with opengl < 3

See commit descriptions for more details.