Add jsonpatch and several bugfix