Move ajax stuff into its own class.