[graphics] Refactor. This is a commit bomb and was not tested