Clean up code comments and add safety to db utilities