Fixed a couple of bugs with opening the files.