Making the mode stack variable length