Better error checking. Some code rearrengment.
control pipe via ioctl() and read() and write() access to bulk and interrupt pipes.