Minimizing index.php and adding pagination to functions.php