Fixed the cycle problem and concatenation issue with terms first appearing after opening parenthesis.