Fix bugs in event and register process.