Fixing various bugs with gadgets