Fix gadget initialization and session handling