More work on the graphics context, also ran a code cleanup.