Fixed infinite loop when using foreach with nil lists.