added an optional cache for library iterating