what you are looking for is in fact a big deal in programming. So much so that it got its own name: Object Oriented Programming, or OOP for short. You can read more about it here: https://en.wikipedia.org/wiki/Object-oriented_programming#Features. There are 4 principles to OOP: encapsulation, abstraction, inheritance, and polymorphism. In essence these principles help you separate your data from your processes as much as possible, and try to ensure that the processes are as modular as possible. To accomplish this you can do two things: (i) find the functions/methods that are performing each step and then break these down into their most modular components; (ii) make sure that your data is not tightly bound to your functions/methods, which you can refer to the 4 OOP principles to see how to think about accomplishing that. If you were able to share your source code here I would be able to help with this process!
Hope this provides a good starting point!