Code cleanup before fdSet
Reimplemented setFd. More test needed.