Merge sync_app.py from upstream