Although I believe that everything in a story is there for a reason, I also believe that not everything is there for a direct contribution to the plot. There could be comments that emphasized the peculiar outfits in a no less particular region or medieval town. It is possible to inform the reader about, for example, the economic consequences of the plague or the fearful state of mind under either an abusive feudal regimen or under the effects of superstition. Understanding Alchemy could be useful for the greatest enjoyment and comprehension of the story. Talking about medieval technology, civil construction or sword forging may be crucial for the reader to understand part of the plot as well to be familiar with the limitations of the Middle Ages. Some of these "themes" could be there for creating an accurate atmosphere or the appropriate physical and mental environment needed for the plot to be plausible. For example, informing the reader about the most absurd superstitions among the medieval people and how serious they took them, creates not only an evocative atmosphere where everything can happen but also prepares the reader's mind to accept any supernatural event as part of the plot. These themes contribute to the story, yes, but not directly acting over the plot necessarily. They don't change the plot but help the plot to be acceptable, making the story more believable.

The diversity of themes
There are themes that help to create a suitable atmosphere. There are also themes that contribute to character development. Some previous events, popular customs, or general beliefs may give hints, as a sort of subtle explanation about the personality of one of our characters. There are themes that give the required explanation to understand the political events of the plot.
In the novel I am currently writing, I have multiple themes: psychological patterns of the parent-child relationship, friendship, social commitment, loyalty, tyranny, alchemy, metallurgy, cryptology, superstition, witch hunting, inquisition, peasant revolts, social-economical aspects of the Middle Ages, and etc. The contribution of all themes, plus effective character development, gives the story its cohesion. In other words, the themes legitimize the story in the reader's mind making it believable, coherent and finally enjoyable.

Plot and themes
The following will set me apart from other writers or theoretical authors. The obvious question is how to integrate all these themes in a way that they flow naturally through the story. Generally, some authors make the themes a subaltern member of the plot. I keep them independent. Instead of theorizing about this method, I will show you what I do.
The lines I am about to write are based on my experience. Although the character development in "The Scratches Of The Steel" is dynamic, in constant progress, it goes hand in hand with the plot. The plot does not change a character, but a character can change the plot. The character is based on a psychological profile that I have chosen at the beginning. This profile is based on the psychological thesis I have chosen for the story. Based on these two elements, characters, and plot, I create a more elaborate draft for the story. Only then, I begin to work on the themes.
In order to develop all the themes, I research as much I can about each of them. I address every theme separately. My readings enrich every theme little by little. I write separate documents for each theme.

The weaving of themes begins
As I said, I already have the dynamic draft of the story. Although my research is not complete, at some point, I begin to feel the need to begin incorporating these themes into the story. So, I start to figure out in what parts of the plot the partial incorporation of one theme is necessary and convenient. I also think of the most adequate way to do it: as part of a dialogue, as a comment of the narrator, from the main character or not, and etc. Since I have not finished my research, these incorporations are also dynamic. In other words, they are subject to further improvement as I research more and more.
Let's say I decide to create a dialogue that will inform the reader about the abusive treatment associated with the witch-hunting theme. This dialogue has to be inserted at a precise moment on the time-line of the story. The plot, already created for that moment, not only will give me the pretext, but also the connections with other moments on the time-line to complete the incorporation of that theme. In this way, I sew the theme along to the story, so to say.

Stitching the themes across themselves
The crossing of themes is important. For example, the dialogue about the abuse of the witch-hunting involves some testimonies from a Jewish physician. I make him briefly recount his education on the Kabbalah. By doing this, I am creating a stitch to weave another theme into the story: cryptology. This brief moment is part of the cryptology theme and will continue at some other point. In this way, the different themes are woven together. Consequently, I create a network of thematic references that flow throughout the story over its time-line. This method makes the incorporation of the themes into the story so much easier and natural.

Making alterations to the plot by stitching the themes into it.
You may wonder, how do I know what point on the time-line is best for one of these stitches? What criteria can I use to place the stitches here and there? What I have done so far is turning this uncertainty into a tool. It seems reasonable the idea of keeping the plot under a sinusoidal variation, between extremes of euphoria and pessimism. It's equally reasonable to anticipate that the reader will be forced to go through a pathway characterized by ascending moments of expectation that eventually go downhill to lowest levels of discouragement, keeping the reader in perpetual interest. I am not going to discuss the theories on the subject here since there are plenty of resources to learn about them. I will say, though, that even for a novel like mine that involves the solving of a crime in the Middle Ages, the events of the plot does not always offer this sinusoidal variation by themselves. Here is when you can place a stitch of a convenient theme. For example, the comments about the horror of the witches' execution, the penetrating smell of burned human flesh spread by the warm wind that is rustled by the bonfires, can replace the dramatic intensity to a weak line of action. In other words, these stitches used as a tool will help the plot to achieve the sinusoidal dramatic shape it should have

A more authorized expositor
Finally, instead of an explanation of this sinusoidal shape of the plot, due to the limitations of this already lengthy article, I will transcribe a post of mine on Facebook (July 12, 2018), and let someone more authorized do the explanation for me:

Very interesting!!! A couple of months ago, I developed this graphical way to understand the plot of a novel in terms of drama to be used in a novel I am currently writing. (see image). Today, I was trying to figure out if somebody has applied node/graph theory to the creation of plots. I could not find anything but I ended up watching a video which surprised me very much. I could see my ideas coming from the mouth of somebody else!!!
AboutKurt Vonnegut:

Good Bye for now and remember, if you can dream of it, you can do it.