Work towards AJAX, move a chunk of PHP, etc.

Work in progress.