Fix bugs in bbcode mode