Fix possible collisions on binding port and handle rex socket