Fix displaced socket contents in undo stack