Make sure failed requests do not cause the server to restart.

Introduce one "request" function which handles all logging and errors. This allows a simplification of the rest of the wsapi calls and ensures that we are not incorrectly handling errors.

fixes issue #28
fixes issue #29
fixes issue #31