Moved determinetextstyle to lib. Tightened up code comments.