String optimization

Replaced the usage of all those
```C#
str += string.Format(...);
```

with much faster StringBuilder. Additionally simplified the creation of query strings.