Stats and Hash improvements.

Stats:
* Added accounting for in-memory index;
* Removed code duplication;
* More consistent stats naming.

Hash:
* Reduced memory usage by ~10%;
* Simplified code;