Add event APIs
Fix compiling errors with CFLAGS=-DNDEBUG