More efficient, works for bactNOGs too.

Not updated for python 3 yet though.