clean up encoder code