Improve events handling