Corrected mulitple IPSC code

Added Adam's contributions to extend the code to an arbitrary number of
IPSCs.