Some fixes to the safe_open() function.