@ericf I think it would be really useful to have some more documentation about what's happening in this file. Do you think you could write a few lines for each function to explain what's happening?