fixed some encoding bugs