Fix issue #365 and #366

Bold/italic nesting fix and toc recursion fix.  See commits for more info.