Fix some bugs related to paragraph processing