Replaced Mantid code by pure python. This refs #6577