Fix <sentence> parsing; clean up code