MSFVenom Load Generation – Information Security Stack Exchange

I can find many examples of using MSFVenom online, but I was curious to know how MSFVenom generates payloads and I did not find much information about it.

Does any one have links that explain how a payload is generated? More specifically, I would like to know how MSFVenom handles the mutation of models to remove unwanted characters, etc.