Major updates to dilution code