add thunk.inputs and thunk.output automatically at many places.
Correctly handle the case where a thunk don't have an inputs fields.