Fix annoying bugs e.g. linefeed/encoding not match