Performance improvements
These changes cut ~200 s off the runtime of the ABTR example sent to me by @nstauff. It mostly is removal of unused indices produced by a lot of enumerate and creation of variables to replace str() calls inside of for-loops. The removal of str had a particularly big effect as it was 1) deducing types, 2) allocating memory for a new string and 3) converting the value to a string for each iteration of those loops.
I then did some refactoring of the fill_model_datastructure. This was mainly to make it easier to follow, but there are some minor optimizations there as well that involve reduced branching of the code resulting in fewer conditional checks.