fix buffer overflow, rename event file and add event handler