Fix frame-dependant timing - shared global variable