Fix encoding glitch, and fix behavior