Refactor AJAX controllers