Fixes Undo/Redo in painting section

Other changes:
Cleaned up bits of code
Added more comments
Slightly altered event creation