quick short fix
Clear the upper bits by a cast to unsigned char
refactored where the fd gets injected into consumers
Refactored main to include fd refactorings
Extra debuggins inside connect
Lots of domain api stuff added