Separate Redis logic and fix sync control flow