Fix infinite loop inside LP. Fix #670.