some collection related bug fixes and some refactoring to prepare for the next set of functionality