Ajax.js integration, refactoring