Added file existence checks.