cleanups, remove memory leaks
more info when reference file reading fails