Fixed bugs with layer memory and undo / redo