more speed improvements - from tightly profiling the code, the bulk of the time is spent in the MySQLdb module :/