Various stat-related bug fixes