Gadget fixes and chaining tests.
Merge branch 'chaining'