Fix const on input buffers. Fix initialization flags. Add return values for sends. Fix non threadsafe singleton instantiation