fixed a few bugs with file processing