AWE #20
FIX: Fixe null ptr on undo 
CHG: Minor code refactoring