Updated functions to handle multiple subjects

Using code received from aozonoff in file inrcalc-20140317.r