Works on the simplified example, but still getting some errors. Investigating.