Cleaned up OpenGL code. Thanks to mmozeiko for feedback.