Fixed some behavior of opening files.