Cleanup and refactor getAppData.php