Refactoring and more stuff for graphics.