ensure uniqueness when incrementing catid (issue #638)