Cleaned up Ajax to be fully functional