See https://github.com/troy/txlogic