Added authenticated() check, improved functions and AJAX expands.