free allocated variable
updated docs, removed printing to stderr
fixed locale/charset support