Allow use of sockets for fsys.dup()
Code cleanup.