Fix CLRF and encoding issues