Implement LimitStack to prevent undo overflow

Signed-off-by: Harsh Gupta <gupta.harsh96@gmail.com>
Fair enough. I wanted to avoid the overhead of having to remember to update length anytime stack changes. But since we only have two methods, I guess it's cool.