Revised the types and added a run function that builds a trace for testing purposes.