Code slimmed/revised for production use. Add functions.php