Gadget: Add typehinting, and don't re-invent some things from core

Change-Id: I75320eccf2513ebae78a49ee6f9ecddba0b884f3
Merge "Gadget: Add typehinting, and don't re-invent some things from core" into RL2