all: bugfixes, expose thread_stats_map to interface

Some funky code going on there. But it works surprisingly well.