Fix bug with removal of dynamically added gadgets