rearrange and reformat functions.php, closes #23