Fix encoding for layers