fixed a but with undo and redo. resources weren't freed after a command was deleted due to the fact that it wasn't reachable anymore ( previous changes)