Various bug fixes

Sending large amounts of data through the service identified
some bugs which have been fixed.
Put a limit on the amount of buffer space a single socket can have