[SYNC] Code improvements, sync with compat

- reorder classes
- use config variables for line_separator, max_retries, retry_wait

Change-Id: Ife68b1c43c72aed06f1ca146ed79edffa4c8b98b
Merge "[SYNC] Code improvements, sync with compat"