graphics repainting fixed, minor refactoring