Improve detection of boundary characters