minor enhancements, encodings, CHARSET, refactoring