Changed to single AJAX requests. Fixed several bugs