some encoding fixes for handler