Fix #102 : Some file streams were left open by krun, causing temp directory move to produce errors. Closed all faulty streams and added some problem diagnosis code.