Added app_data logic and support files for passing referrals