Revise the Graphic class

Improve the memory management.