Added loading functionality, better event handling and dispatch