Bug fixes for overlapping phrases, more test cases