Fix a bug with sockets not closing
Fix a logic error with operator precedence