Destroy file fix and a bit refactoring