AJAX and JS bugs fixed