Small simplifications
Remove redundant declaration
Add a state result to socket_close and socket_partial_close