Made return values in DB code more consistent with enums and added more checks