Import improvements to mapping and statistics to the main branch.