added a wealth of comments to functions.php to restore order