Text encoding fixed; cleanup