Added possibility to emit events and removed the scope argument + code cleanup