Cleared opengl states correctly.

Fixed various bad code styles and comments.