updated encoding to UTF-8, added debugging option