added some more (untested) wrapping of inputs and outputs