Refactor synchronization script, phase 1.

Remove most of PyCharm's warnings and improve style a bit.

Change-Id: I622bc0ef41c38bbd613172481edb0ee0b861c262
Merge "Refactor synchronization script, phase 1."