Added functions to detect opening, closing and matching braces.