bug fixes and handling reach end of events