brought over logic for keeping track of stage directions and formatting