improve hierarchy generation; see #821