Bugfix event loop (popping the wrong element...)
Add ping (not tested) + minor improvements.