fixing some bugs (including #123)