Improved stats handling, added sorted dump