add a bunch of assertions
lift this out of the loop
don't need to expose any of these to perl anymore