fixed segfault bug where file loader destructor was being called too soon