Cleanup and fix the ajax stuff