Database: Fixed a bug that wasn't getting the revision for the latest entities and also cleaned up the code to remove method duplication.