Revised some of the database logic checks in API code