This reverts commit 8d2885c2. I accidentally introduced an infinite loop in this patch, will return when this is fixed.