login page: write a 'logout' handler
cleanup: avoid a bunch of PHP warnings
cleanup: rewrite to avoid php warnings