improved message handling and added server send method