Implement LimitStack to prevent undo overflow

Signed-off-by: Harsh Gupta <gupta.harsh96@gmail.com>
I think `length` should be a function (that simply returns `stack.length`), not a property. Any strong reasons for doing it this way?