Adds an undo stack

Implementation of undo command (max 1000)
Must be enabled by setundobuffer(N) where 0 < n < 1000