Added a check for AJAX calls so that forms don't get removed prematurely from the session.