Remove NULL characters from buffer streams
Fixed some bugs in the webserver
After a big valgrind memory check, the following changes were made

1) Fixed all memory leaks in the main daemon.

2) Made threads initialization functions platform independent.

3) Nearly all threads will now gracefully close instead of
being forced to. To allows this, some adaptations where
necessary.
- The socket select function needed to be woken up so they
stopped blocking the execution of a thread. To allow
this several loopback connection were made to send
a single bit to the socket connection while garbage collecting
- All mutexes are unlocked and thread conditions are signaled.

4) Some thread helper function have been added to the protocol
library. This makes protocol writing easier. It also
allows threads to gracefully stop like described in point 3.

5) A special garbage collector function was added to the protocol
library. When the protocols are freed the protocol specific "gc"
function is called first. This allows protocols to free their local
resources first.