Added flash handling for AJAX