Use new style string formatting, rather than sprintf style
Reorganized imports. Use ujson instead of json if it is available (ujson is faster).