fix some bugs introduced in the functionalization