Added client.disconnect() and fixed a few things.