Some code cleanup for sync