Added functionality and fixed bugs

- Added server message function
- Added client exit handler
- Fixed bugs
- some minor changes