Corrected bugs in the db access code for new tags API