Backported "scoped_session is all that we need", use ujson and small bugfix.