void CleanupOutput(char *str)
{
    char *s, *t;
    int period = 0;
    s = t = str;
    while ( *s && *s != '}' ) {
        if ( *s == '\n' ) *s = ' ';
        if ( ( *s == ' ' || *s == '\n' ) && ( s[1] == ' ' || s[1] == '\n' ) ) s++;
        else *t++ = *s++;
    }
    while ( *s ) *t++ = *s++;
    *t = 0;
    s = t = str;
    while ( *s ) {
        if ( *s == '.' ) { period = 1; *t++ = *s++; }
        else if ( *s == '-' && s[1] == '0' && s[2] == ' ' ) { s++; }
        else if ( *s <= '9' && *s >= '0' ) { *t++ = *s++; }
        else if ( *s == '\n' && ( t > str && t[-1] == '\n' ) ) { s++; }
        else if ( period ) {
            while ( t > str && t[-1] == '0' ) t--;
            if ( t > str && t[-1] == '.' ) t--;
            while ( *s == ' ' && s[1] == ' ' ) s++;
            period = 0; *t++ = *s++;
        }
        else if ( *s == ' ' && s[1] == ' ' ) s++;
        else {
            period = 0; *t++ = *s++;
        }
    }
    *t = 0;
    s = t = str;
    while ( *s ) {
        if ( *s == '-' && s[1] == '0' && s[2] == ' ' ) { s++; }
        else *t++ = *s++;
    }
    *t = 0;
}