Cleanup and fixes to stage count in maptier.