made pylab an optional import and removed some unused imports