fix encoding, some bugs)