Optimized frame limit sleep

Tried to fix #4431 and follow all advises from @pchote.