More cleanup to encoding