added relay/socket and fixed device handling