Fixed key/partitioning, fixed stats reporting, added unit tests