Move common functionality to a utils file.
Remove dead code.
Refactoring ajax to use utils. dispatch model.