Adapted handler to manage contexts, improved the gadget.