Tidy up code, earn rep for referrals and notify users on refer