New mapping statistics, lots of refactoring, fixes