Moved stats gathering in stats module