Refactoring, fixed edit ajax bug, fixed ajax refresh