Fix reason encoding