Fixed event dispatching and added some documentation.