Improved fix for ERRAI-745 to work with all collection types