Use range() instead of xrange()
Remove itertools.izip() usage
Fix StringIO usage