Moved stats handling in its own file.