FIX: Infinite loop in some cases.