Fix global variable leak

Due to an error in their declaration, the variables `sub_sock`, `rpc_sock` and `md` leaks in the global scope.