cleaned some more and fixed bug in totex