Consolidated stuff for a final commit before moving to Pyglet.