Fix some bugs when switching to get_by_id() in ndb