r5197: moved events code to lib/events/ (suggestion from metze)