fix bugs, now generating expr for gadgets is done