Added invariant mass calculation, and better idiot proofing