massive debugging code to troubleshoot sync issues