Cleanup and fix client deallocation.

Clients are now removed and deallocated properly.