bug fix: order of sync operations in sync()