Lots of changes due to switch to median from mean values