You cannot store ID (or any other data) pointers accross undo’s/redo’s, those are reading .blend file and hence invalidating all pointers! Not that happy with this fix, code is rather convoluted and not elegant at all, but cannot think of a better solution, so will do for now. Also found and fixed another 'str ghash used for int keys' case...