More refactoring for Ajax