Integrated updateCollectionStats code (previously a stored procedure)

...e)