Fixed many bugs in Thurston algo