Some encode fixes