Fixes to avoid looping behavior.