Fix some bugs (introduce some new)