Fixed bug in deletion of intermediate files