Refactor the graphics implementation.