updated to use pl.close() for closing plot images. No reason to keep them open in most cases.