Changed import of scipy to numpy wherever possible to prepare way for pypy.