SQL fixes and improvements

Fixed duplicate types, tags displaying in search operations, and tag
formatting