Moved all the collection stuff out of the controller.