Adding multi-collection support, courtesy of David Ross Smith