Fixed small bug in layout and started undo functionality.