refactoring and add sentence detector, ambiguities resolved variables