0.3 rc2: use maps for stats + many other stuff

A big one. Next on the todo list is to change the indexing of threads to 0:N instead of 1:N+1.