Sockets secure implementations

Rebased on `master`.
Don't pass a JSONObject to implementation methods. Much better to extract any needed args here and pass them in explicitly.