Add more checks and database cleanup in yum

Change-Id: I5ecb28ba6bd3e18070718de1031e83d994449b48
Closes-Bug: #1323999
Merge "Add more checks and database cleanup in yum"