fix some bugs/type signatures