Add proper timeout handling
Refactor client handling on server