Refactor main/graphics interaction