A lot of this code can be cleaned up because it's really not going to be necessary anymore. I have not yet gotten to that because during development I'm trying to keep compatibility with our old template engine so I can switch to it by changing the services.yml file and compare the output to make sure things are being parsed correctly.