improve code for nes main thread looping, fix frame rate accuracy issue.