Make relay server much more robust and implement CLI client for testing