Switched over to using tabs instead of spaces.
Also attempted to indent the code in a much better way.
Changed the links on thae image attachment pages to only link to other images in the same gallery