Added event dispatching and fixed some issues