Simulation cleanup

* Change closure actions to top level functions (prevents re-building)
* make flake8 complain less