Improve speed - use cStringIO instead of StringIO.