Cleaned up the AJAX stuff a bit