Revert the ensure_directory check as it doesn't work at all