Fixed those undefined phantom variables...
Changed order of the loops so now when faced with an odd number of links to display, our current page will be right in the middle.