Add methods for db operations. Modify events to use methods.