clean up dead code and honour the encoding config