Added some selector and event and database managment.