added separate graphics and mainloop
changed timer to queryperformancetimer