Implement LimitStack to prevent undo overflow

Signed-off-by: Harsh Gupta <gupta.harsh96@gmail.com>
Not a very strong reason, but I wanted to use the same API as Arrays.