Move variables to context
Clean up connection code
Unify next connect timeout