Fixed some bugs on events generation