Fixed a bug with emitting the mode event