Make shared_ptr use more consistent.
Fix crash trying to compute a file location at end of file.