Fixed misc. bugs

Fixed a few bugs involving checking for characters after a T
non-terminal, as well as a few control statements that did not backtrack
when needed.