Added Transaction wrappers for each of the functions. Database code goes inside the funcitons and is automatically handled transactionally.