fix bugs. refactor. add missing gfx