Rerolled core patch to fix #states