Multiple bug fixes in this branch - testing changes by running with plot_lightcurve still does not work, but is closer to working