Fixes of some bugs