Way less globals

Lets see if the commit comments appear here
Why do we have to have get_socket as an argument?