Thread and other functions works bit stable now.
Add sleep time for sync when got period limit.