Fixed infinite loops