support for in and out devices and various fixes