Removed some debug stuff and added error handling for ajax.